Skip to content

Commit

Permalink
fix: fix jsr publish flow
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Dec 3, 2024
1 parent 21ee65a commit 240386b
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 19 deletions.
47 changes: 47 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@
"build:dts": "tsc --emitDeclarationOnly --outDir target/dts",
"build:docs": "typedoc --options src/main/typedoc",
"build:stamp": "npx buildstamp",
"build:jsr": "node ./src/scripts/build-jsr.mjs",
"test": "concurrently 'npm:test:*'",
"test:target": "git diff --exit-code --quiet || (echo 'Uncommitted changes' && exit 1)",
"test:lint": "eslint -c src/test/lint/.eslintrc.json src",
"test:unit": "c8 -r lcov -r text -o target/coverage -x src/scripts -x src/test -x target node --loader ts-node/esm --experimental-specifier-resolution=node src/scripts/test.mjs",
"test:smoke:esm": "node ./src/test/smoke/invoke.test.mjs",
"test:smoke:cjs": "node src/test/smoke/invoke.test.cjs",
"test:jsr": "jsr publish --dry-run",
"test:audit": "npm audit",
"publish:draft": "npm run build && npm publish --no-git-tag-version"
},
Expand All @@ -62,7 +64,6 @@
"url": "https://github.com/webpod/zurk/issues"
},
"homepage": "https://github.com/webpod/zurk#readme",
"dependencies": {},
"devDependencies": {
"@types/node": "^22.10.1",
"c8": "^10.1.2",
Expand All @@ -76,6 +77,7 @@
"eslint": "^8.57.0",
"eslint-config-qiwi": "^2.1.6",
"fast-glob": "^3.3.2",
"jsr": "^0.13.2",
"minimist": "^1.2.8",
"ts-node": "^10.9.2",
"typedoc": "^0.27.2",
Expand Down
4 changes: 2 additions & 2 deletions src/main/ts/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const normalizeCtx = (...ctxs: TSpawnCtx[]): TSpawnCtxNormalized => assig
get signal() { return this.ac?.signal }},
...ctxs)

export const processInput = (child: TChild, input?: TInput | null) => {
export const processInput = (child: TChild, input?: TInput | null): void => {
if (input && child.stdin && !child.stdin.destroyed) {
if (input instanceof Stream) {
input.pipe(child.stdin)
Expand Down Expand Up @@ -140,7 +140,7 @@ export const buildSpawnOpts = ({spawnOpts, stdio, cwd, shell, input, env, detach
signal
})

export const toggleListeners = (pos: 'on' | 'off', ee: EventEmitter, on: Partial<TSpawnListeners> = {}) => {
export const toggleListeners = (pos: 'on' | 'off', ee: EventEmitter, on: Partial<TSpawnListeners> = {}): void => {
for (const [name, listener] of Object.entries(on)) {
ee[pos](name, listener as any)
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/ts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Buffer } from 'node:buffer'

export const g = (!process.versions.deno && global) || globalThis

export const immediate = g.setImmediate || ((f: any) => g.setTimeout(f, 0))
export const immediate = g.setImmediate || ((f: any): NodeJS.Timeout => g.setTimeout(f, 0))

export const noop = () => { /* noop */ }

export const asyncVoidCall = (cb: TVoidCallback)=> async () => { await cb() }
export const asyncVoidCall = (cb: TVoidCallback)=> async (): Promise<void> => { await cb() }

export const randomId = () => Math.random().toString(36).slice(2)
export const randomId = (): string => Math.random().toString(36).slice(2)

export type PromiseResolve<T = any> = (value: T | PromiseLike<T>) => void

Expand Down Expand Up @@ -46,7 +46,7 @@ export const assign = <T, E>(target: T, ...extras: E[]): T =>
({...m, ...Object.fromEntries(Object.entries(Object.getOwnPropertyDescriptors(extra))
.filter(([,v]) => !Object.prototype.hasOwnProperty.call(v, 'value') || v.value !== undefined))}), {}))

export const quote = (arg: string) => {
export const quote = (arg: string): string => {
if (/^[\w./:=@-]+$/i.test(arg) || arg === '') {
return arg
}
Expand Down Expand Up @@ -101,4 +101,4 @@ export const parseInput = (input: any): string | Buffer | Stream | null => {
return null
}

export const pFinally = (p: Promise<any>, cb: TVoidCallback) => p.finally?.(asyncVoidCall(cb)) || p.then(asyncVoidCall(cb), asyncVoidCall(cb))
export const pFinally = (p: Promise<any>, cb: TVoidCallback): Promise<void> => p.finally?.(asyncVoidCall(cb)) || p.then(asyncVoidCall(cb), asyncVoidCall(cb))
2 changes: 1 addition & 1 deletion src/main/ts/x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const zurkMixin: TMixin = ($: TShell, target: TShellOptions | TZurk | TZurkPromi

$.mixins = [zurkMixin, killMixin, pipeMixin, timeoutMixin]

export const applyMixins = ($: TShell, result: TZurk | TZurkPromise | TShellOptions, parent?: TZurk | TZurkPromise) => {
export const applyMixins = ($: TShell, result: TZurk | TZurkPromise | TShellOptions, parent?: TZurk | TZurkPromise): TZurk | TZurkPromise | TShellOptions => {
let ctx: TShellCtx = (parent as TZurkPromise | TZurk)?.ctx

return $.mixins.reduce((r, m) => {
Expand Down
8 changes: 4 additions & 4 deletions src/main/ts/zurk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ export const zurkSync = (opts: TZurkOptions): TZurk => {
}

// eslint-disable-next-line sonarjs/cognitive-complexity
export const zurkifyPromise = (target: Promise<TZurk> | TZurkPromise, ctx: TSpawnCtxNormalized) => {
if (isZurkProxy(target) || !isPromiseLike(target)) {
export const zurkifyPromise = (target: Promise<TZurk> | TZurkPromise, ctx: TSpawnCtxNormalized): TZurkPromise => {
if (isZurkProxy(target) || !isPromiseLike(target))
return target as TZurkPromise
}

const proxy = new Proxy(target, {
get(target: Promise<TZurk>, p: string | symbol, receiver: any): any {
if (p === ZURKPROXY) return ZURKPROXY
Expand All @@ -102,7 +102,7 @@ export const zurkifyPromise = (target: Promise<TZurk> | TZurkPromise, ctx: TSpaw
return proxy
}

export const getError = (data: TSpawnResult) => {
export const getError = (data: TSpawnResult): Error | null => {
if (data.error) return data.error
if (data.status) return new Error(`Command failed with exit code ${data.status}`)
if (data.signal) return new Error(`Command failed with signal ${data.signal}`)
Expand Down
3 changes: 1 addition & 2 deletions target/cjs/zurk.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ var zurkSync = (opts) => {
return response;
};
var zurkifyPromise = (target, ctx) => {
if (isZurkProxy(target) || !(0, import_util.isPromiseLike)(target)) {
if (isZurkProxy(target) || !(0, import_util.isPromiseLike)(target))
return target;
}
const proxy = new Proxy(target, {
get(target2, p, receiver) {
if (p === ZURKPROXY) return ZURKPROXY;
Expand Down
2 changes: 1 addition & 1 deletion target/dts/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export declare const buildCmd: (quote: TQuote, pieces: TemplateStringsArray, arg
export type TSubstitute = (arg: any) => string;
export declare const substitute: TSubstitute;
export declare const parseInput: (input: any) => string | Buffer | Stream | null;
export declare const pFinally: (p: Promise<any>, cb: TVoidCallback) => Promise<any>;
export declare const pFinally: (p: Promise<any>, cb: TVoidCallback) => Promise<void>;
2 changes: 1 addition & 1 deletion target/dts/zurk.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export declare const zurk: <T extends TZurkOptions = Partial<Omit<TZurkCtx, "cal
export declare const zurkAsync: (opts: TZurkOptions) => TZurkPromise;
export declare const zurkSync: (opts: TZurkOptions) => TZurk;
export declare const zurkifyPromise: (target: Promise<TZurk> | TZurkPromise, ctx: TSpawnCtxNormalized) => TZurkPromise;
export declare const getError: (data: TSpawnResult) => any;
export declare const getError: (data: TSpawnResult) => Error | null;
export declare const isZurkAny: (o: any) => o is TZurk | TZurkPromise;
export declare const isZurk: (o: any) => o is TZurk;
export declare const isZurkPromise: (o: any) => o is TZurkPromise;
Expand Down
3 changes: 1 addition & 2 deletions target/esm/zurk.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ var zurkSync = (opts) => {
return response;
};
var zurkifyPromise = (target, ctx) => {
if (isZurkProxy(target) || !isPromiseLike(target)) {
if (isZurkProxy(target) || !isPromiseLike(target))
return target;
}
const proxy = new Proxy(target, {
get(target2, p, receiver) {
if (p === ZURKPROXY) return ZURKPROXY;
Expand Down

0 comments on commit 240386b

Please sign in to comment.