@shopify/cli-kit 3.3.2 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/api/admin.js +20 -34
- package/dist/api/admin.js.map +1 -1
- package/dist/api/common.d.ts +11 -1
- package/dist/api/common.js +50 -4
- package/dist/api/common.js.map +1 -1
- package/dist/api/identity.js +3 -3
- package/dist/api/identity.js.map +1 -1
- package/dist/api/partners.d.ts +0 -5
- package/dist/api/partners.js +22 -42
- package/dist/api/partners.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -2
- package/dist/constants.js.map +1 -1
- package/dist/environment/local.d.ts +1 -0
- package/dist/environment/local.js +3 -0
- package/dist/environment/local.js.map +1 -1
- package/dist/environment/service.d.ts +2 -1
- package/dist/environment/service.js +16 -0
- package/dist/environment/service.js.map +1 -1
- package/dist/error.d.ts +5 -0
- package/dist/error.js +10 -4
- package/dist/error.js.map +1 -1
- package/dist/file.d.ts +2 -0
- package/dist/file.js +13 -1
- package/dist/file.js.map +1 -1
- package/dist/git.js +12 -4
- package/dist/git.js.map +1 -1
- package/dist/http/fetch.d.ts +9 -2
- package/dist/http/fetch.js +11 -2
- package/dist/http/fetch.js.map +1 -1
- package/dist/http/graphql.d.ts +15 -0
- package/dist/http/graphql.js +12 -0
- package/dist/http/graphql.js.map +1 -0
- package/dist/http.d.ts +24 -0
- package/dist/http.js +27 -0
- package/dist/http.js.map +1 -1
- package/dist/network/service.d.ts +1 -1
- package/dist/network/service.js.map +1 -1
- package/dist/node/archiver.d.ts +4 -1
- package/dist/node/archiver.js +22 -13
- package/dist/node/archiver.js.map +1 -1
- package/dist/node/base-command.d.ts +1 -0
- package/dist/node/base-command.js +10 -1
- package/dist/node/base-command.js.map +1 -1
- package/dist/node/cli.d.ts +0 -2
- package/dist/node/cli.js +0 -4
- package/dist/node/cli.js.map +1 -1
- package/dist/node/error-handler.d.ts +20 -0
- package/dist/node/error-handler.js +40 -3
- package/dist/node/error-handler.js.map +1 -1
- package/dist/node/hooks/init.d.ts +2 -0
- package/dist/node/hooks/init.js +7 -0
- package/dist/node/hooks/init.js.map +1 -0
- package/dist/node/hooks/postrun.js +4 -1
- package/dist/node/hooks/postrun.js.map +1 -1
- package/dist/node/hooks/prerun.js +2 -0
- package/dist/node/hooks/prerun.js.map +1 -1
- package/dist/node/ruby.d.ts +7 -2
- package/dist/node/ruby.js +24 -12
- package/dist/node/ruby.js.map +1 -1
- package/dist/output.d.ts +18 -11
- package/dist/output.js +96 -28
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +3 -3
- package/dist/path.js +2 -4
- package/dist/path.js.map +1 -1
- package/dist/session/exchange.js +2 -2
- package/dist/session/exchange.js.map +1 -1
- package/dist/session/validate.js +3 -0
- package/dist/session/validate.js.map +1 -1
- package/dist/session.js +7 -1
- package/dist/session.js.map +1 -1
- package/dist/store.js +0 -2
- package/dist/store.js.map +1 -1
- package/dist/string.js +3 -1
- package/dist/string.js.map +1 -1
- package/dist/system.d.ts +4 -3
- package/dist/system.js +5 -2
- package/dist/system.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing/overloaded-parameters.d.ts +6 -0
- package/dist/typing/overloaded-parameters.js +2 -0
- package/dist/typing/overloaded-parameters.js.map +1 -0
- package/dist/typing/simple-definitions.d.ts +4 -0
- package/dist/typing/simple-definitions.js +2 -0
- package/dist/typing/simple-definitions.js.map +1 -0
- package/dist/ui.d.ts +11 -0
- package/dist/ui.js +35 -5
- package/dist/ui.js.map +1 -1
- package/package.json +25 -20
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,gBAAgB,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAC,
|
|
1
|
+
{"version":3,"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IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAK,KAAe,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QAChD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,OAAO,SAAS,CAAC,QAAQ,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["import {Message, stringifyMessage, error as outputError} from './output.js'\nimport {normalize} from './path.js'\nimport {Errors} from '@oclif/core'\n\nexport {ExtendableError} from 'ts-error'\nexport {AbortSignal} from 'abort-controller'\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class Fatal extends Error {\n tryMessage: string | null\n type: FatalErrorType\n constructor(message: Message, type: FatalErrorType, tryMessage: Message | null = null) {\n super(stringifyMessage(message))\n this.tryMessage = tryMessage ? stringifyMessage(tryMessage) : null\n this.type = type\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer\n */\nexport class Abort extends Fatal {\n constructor(message: Message, tryMessage: Message | null = null) {\n super(message, FatalErrorType.Abort, tryMessage)\n }\n}\n\nexport class AbortSilent extends Fatal {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class Bug extends Fatal {\n constructor(message: Message, tryMessage: string | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n * @param error Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: Error): Promise<Error> {\n let fatal: Fatal\n if (isFatal(error)) {\n fatal = error as Fatal\n } else if (typeof error === 'string') {\n fatal = new Bug(error as string)\n } else {\n fatal = new Bug(error.message)\n fatal.stack = error.stack\n }\n\n if (fatal.type === FatalErrorType.Bug) {\n fatal.stack = error.stack\n }\n\n await outputError(fatal)\n return Promise.resolve(error)\n}\n\nexport function mapper(error: Error): Promise<Error> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new Abort(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\nexport function isFatal(error: Error): boolean {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n}\n\nexport function shouldReport(error: Error): boolean {\n if (!isFatal(error)) {\n return true\n }\n if ((error as Fatal).type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n\n/**\n * Stack traces usually have file:// - we strip that and also remove the Windows drive designation\n *\n */\nexport function cleanSingleStackTracePath(filePath: string): string {\n return normalize(filePath)\n .replace('file:/', '/')\n .replace(/^\\/?[A-Z]:/, '')\n}\n"]}
|
package/dist/file.d.ts
CHANGED
|
@@ -19,10 +19,12 @@ export declare function readSync(path: string, options?: object): string;
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function copy(from: string, to: string): Promise<void>;
|
|
21
21
|
export declare function touch(path: string): Promise<void>;
|
|
22
|
+
export declare function appendFile(path: string, content: string): Promise<void>;
|
|
22
23
|
export declare function touchSync(path: string): Promise<void>;
|
|
23
24
|
export declare function write(path: string, data: string): Promise<void>;
|
|
24
25
|
export declare function writeSync(path: string, data: string): void;
|
|
25
26
|
export declare function append(path: string, data: string): Promise<void>;
|
|
27
|
+
export declare function appendSync(path: string, data: string): void;
|
|
26
28
|
export declare function mkdir(path: string): Promise<void>;
|
|
27
29
|
export declare function mkdirSync(path: string): void;
|
|
28
30
|
export declare function remove(path: string): Promise<void>;
|
package/dist/file.js
CHANGED
|
@@ -50,6 +50,15 @@ export async function touch(path) {
|
|
|
50
50
|
debug(outputContent `Creating an empty file at ${token.path(path)}...`);
|
|
51
51
|
await fs.ensureFile(path);
|
|
52
52
|
}
|
|
53
|
+
export async function appendFile(path, content) {
|
|
54
|
+
debug(outputContent `Appending the following content to ${token.path(path)}:
|
|
55
|
+
${content
|
|
56
|
+
.split('\n')
|
|
57
|
+
.map((line) => ` ${line}`)
|
|
58
|
+
.join('\n')}
|
|
59
|
+
`);
|
|
60
|
+
await fs.appendFile(path, content);
|
|
61
|
+
}
|
|
53
62
|
export async function touchSync(path) {
|
|
54
63
|
debug(outputContent `Creating an empty file at ${token.path(path)}...`);
|
|
55
64
|
await fs.ensureFileSync(path);
|
|
@@ -65,12 +74,15 @@ export function writeSync(path, data) {
|
|
|
65
74
|
export async function append(path, data) {
|
|
66
75
|
await fs.appendFile(path, data);
|
|
67
76
|
}
|
|
77
|
+
export function appendSync(path, data) {
|
|
78
|
+
fs.appendFileSync(path, data);
|
|
79
|
+
}
|
|
68
80
|
export async function mkdir(path) {
|
|
69
81
|
debug(outputContent `Creating directory at ${token.path(path)}...`);
|
|
70
82
|
await fs.mkdirp(path);
|
|
71
83
|
}
|
|
72
84
|
export function mkdirSync(path) {
|
|
73
|
-
debug(outputContent `Sync-
|
|
85
|
+
debug(outputContent `Sync-creating directory at ${token.path(path)}...`);
|
|
74
86
|
fs.mkdirpSync(path);
|
|
75
87
|
}
|
|
76
88
|
export async function remove(path) {
|
package/dist/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAC,sBAAsB,EAAC,MAAM,OAAO,CAAA;AAC5C,O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QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,OAAuB;IACnE,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,cAAc,GAAY;QAC9B,GAAG,uBAAuB;QAC1B,MAAM,EAAE,OAAO;KAChB,CAAA;IAED,QAAQ,GAAG,EAAE;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,cAAc,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACpC,MAAK;KACR;IAED,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAEvE,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import {content as outputContent, token, debug} from './output.js'\nimport fs from 'fs-extra'\nimport del from 'del'\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport prettier from 'prettier'\nimport type {Options} from 'prettier'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\nexport function stripUp(path: string, strip: number) {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle ot the lifecycle of the callback.\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding\n * @param path {string} Path to the file to read.\n * @returns {Promise<string>} A promise that resolves with the content of the file.\n */\nexport async function read(path: string, options: object = {encoding: 'utf-8'}): Promise<string> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n const content = await fs.readFile(path, options)\n return content\n}\n\nexport function readSync(path: string, options: object = {encoding: 'utf-8'}): string {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n const content = fs.readFileSync(path, options)\n return content.toString()\n}\n\n/**\n * Copies a file\n * @param from {string} Path to the directory or file to be copied.\n * @param to {string} Destination path.\n */\nexport async function copy(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fs.copy(from, to)\n}\n\nexport async function touch(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFile(path)\n}\n\nexport async function touchSync(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFileSync(path)\n}\n\nexport async function write(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fs.writeFile(path, data)\n}\n\nexport function writeSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fs.writeFileSync(path, data)\n}\n\nexport async function append(path: string, data: string): Promise<void> {\n await fs.appendFile(path, data)\n}\n\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fs.mkdirp(path)\n}\n\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-reating directory at ${token.path(path)}...`)\n fs.mkdirpSync(path)\n}\n\nexport async function remove(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fs.remove(path)\n}\n\nexport async function rmdir(path: string, {force}: {force?: boolean} = {}): Promise<void> {\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force})\n}\n\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fs.mkdtemp('tmp-')\n return directory\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fs.promises.lstat(path)).isDirectory()\n}\n\nexport async function size(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fs.stat(path)).size\n}\n\nexport function sizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fs.statSync(path).size\n}\n\n/**\n * Moves a file.\n * @param src {string} File to be moved.\n * @param dest {string} Path to be moved to.\n * @param options {object} Moving options.\n */\nexport async function move(src: string, dest: string, options: {overwrite?: boolean} = {}): Promise<void> {\n await fs.move(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n * @param path {string} Path to the file or directory whose permissions will be modified.\n * @param mode {string | numbers} Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fs.promises.chmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n * @param path {string} Path to the file whose permissions will be checked.\n */\nexport async function hasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path, fs.constants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists\n * @param path {string} Path to the directory or file.\n * @returns {boolean} True if it exists.\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n */\nexport async function format(content: string, options: {path: string}) {\n const ext = extname(options.path)\n const prettierConfig: Options = {\n ...DEFAULT_PRETTIER_CONFIG,\n parser: 'babel',\n }\n\n switch (ext) {\n case '.html':\n case '.css':\n prettierConfig.parser = ext.slice(1)\n break\n }\n\n const formattedContent = await prettier.format(content, prettierConfig)\n\n return formattedContent\n}\n"]}
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"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AAK;KACR;IAED,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAEvE,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import {content as outputContent, token, debug} from './output.js'\nimport fs from 'fs-extra'\nimport del from 'del'\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport prettier from 'prettier'\nimport type {Options} from 'prettier'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\nexport function stripUp(path: string, strip: number) {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle ot the lifecycle of the callback.\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding\n * @param path {string} Path to the file to read.\n * @returns {Promise<string>} A promise that resolves with the content of the file.\n */\nexport async function read(path: string, options: object = {encoding: 'utf-8'}): Promise<string> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n const content = await fs.readFile(path, options)\n return content\n}\n\nexport function readSync(path: string, options: object = {encoding: 'utf-8'}): string {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n const content = fs.readFileSync(path, options)\n return content.toString()\n}\n\n/**\n * Copies a file\n * @param from {string} Path to the directory or file to be copied.\n * @param to {string} Destination path.\n */\nexport async function copy(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fs.copy(from, to)\n}\n\nexport async function touch(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFile(path)\n}\n\nexport async function appendFile(path: string, content: string): Promise<void> {\n debug(outputContent`Appending the following content to ${token.path(path)}:\n ${content\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')}\n `)\n await fs.appendFile(path, content)\n}\n\nexport async function touchSync(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFileSync(path)\n}\n\nexport async function write(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fs.writeFile(path, data)\n}\n\nexport function writeSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fs.writeFileSync(path, data)\n}\n\nexport async function append(path: string, data: string): Promise<void> {\n await fs.appendFile(path, data)\n}\n\nexport function appendSync(path: string, data: string): void {\n fs.appendFileSync(path, data)\n}\n\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fs.mkdirp(path)\n}\n\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-creating directory at ${token.path(path)}...`)\n fs.mkdirpSync(path)\n}\n\nexport async function remove(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fs.remove(path)\n}\n\nexport async function rmdir(path: string, {force}: {force?: boolean} = {}): Promise<void> {\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force})\n}\n\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fs.mkdtemp('tmp-')\n return directory\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fs.promises.lstat(path)).isDirectory()\n}\n\nexport async function size(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fs.stat(path)).size\n}\n\nexport function sizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fs.statSync(path).size\n}\n\n/**\n * Moves a file.\n * @param src {string} File to be moved.\n * @param dest {string} Path to be moved to.\n * @param options {object} Moving options.\n */\nexport async function move(src: string, dest: string, options: {overwrite?: boolean} = {}): Promise<void> {\n await fs.move(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n * @param path {string} Path to the file or directory whose permissions will be modified.\n * @param mode {string | numbers} Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fs.promises.chmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n * @param path {string} Path to the file whose permissions will be checked.\n */\nexport async function hasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path, fs.constants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists\n * @param path {string} Path to the directory or file.\n * @returns {boolean} True if it exists.\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n */\nexport async function format(content: string, options: {path: string}) {\n const ext = extname(options.path)\n const prettierConfig: Options = {\n ...DEFAULT_PRETTIER_CONFIG,\n parser: 'babel',\n }\n\n switch (ext) {\n case '.html':\n case '.css':\n prettierConfig.parser = ext.slice(1)\n break\n }\n\n const formattedContent = await prettier.format(content, prettierConfig)\n\n return formattedContent\n}\n"]}
|
package/dist/git.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Abort } from './error.js';
|
|
2
|
-
import { hasGit } from './environment/local.js';
|
|
2
|
+
import { hasGit, isTerminalInteractive } from './environment/local.js';
|
|
3
3
|
import { content, token, debug } from './output.js';
|
|
4
4
|
import git from 'simple-git';
|
|
5
5
|
export const factory = git;
|
|
@@ -28,13 +28,21 @@ export async function downloadRepository({ repoUrl, destination, progressUpdater
|
|
|
28
28
|
if (progressUpdater)
|
|
29
29
|
progressUpdater(updateString);
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const simpleGitOptions = {
|
|
32
|
+
progress,
|
|
33
|
+
...(!isTerminalInteractive() && { config: ['core.askpass=true'] }),
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
await git(simpleGitOptions).clone(repository, destination, options);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (err instanceof Error) {
|
|
33
40
|
const abortError = new Abort(err.message);
|
|
34
41
|
abortError.stack = err.stack;
|
|
35
42
|
throw abortError;
|
|
36
43
|
}
|
|
37
|
-
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
/**
|
|
40
48
|
* If "git" is not present in the environment it throws
|
package/dist/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,GAA0C,MAAM,YAAY,CAAA;AAEnE,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAE1B,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO,IAAI,KAAK,CACd,iDAAiD,EACjD,OAAO,CAAA,WAAW,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,+DAA+D,CAAC,EAAE,CACvG,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,SAAiB;IAC1D,KAAK,CAAC,OAAO,CAAA,kCAA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KACpE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,KAAK,EAAE;YACxB,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACzC,UAAU,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;YAC5B,MAAM,UAAU,CAAA;SACjB;QACD,MAAM,GAAG,CAAA;KACV;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,EAAE;QACrB,MAAM,kBAAkB,EAAE,CAAA;KAC3B;AACH,CAAC","sourcesContent":["import {Abort} from './error.js'\nimport {hasGit, isTerminalInteractive} from './environment/local.js'\nimport {content, token, debug} from './output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent} from 'simple-git'\n\nexport const factory = git\n\nexport const GitNotPresentError = () => {\n return new Abort(\n `Git is necessary in the environment to continue`,\n content`Install ${token.link('git', 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git')}`,\n )\n}\n\nexport async function initializeRepository(directory: string) {\n debug(content`Initializing git repository at ${token.path(directory)}...`)\n await ensurePresentOrAbort()\n await git(directory).init()\n}\n\nexport async function downloadRepository({\n repoUrl,\n destination,\n progressUpdater,\n shallow,\n}: {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n}) {\n debug(content`Git-cloning repository ${repoUrl} into ${token.path(destination)}...`)\n await ensurePresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const options: TaskOptions = {'--recurse-submodules': null}\n if (branch) {\n options['--branch'] = branch\n }\n if (shallow) {\n options['--depth'] = 1\n }\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n await git(simpleGitOptions).clone(repository, destination, options)\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new Abort(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensurePresentOrAbort() {\n if (!(await hasGit())) {\n throw GitNotPresentError()\n }\n}\n"]}
|
package/dist/http/fetch.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Service } from '../network/service.js';
|
|
1
2
|
import nodeFetch from 'node-fetch';
|
|
2
3
|
import type { RequestInfo, RequestInit } from 'node-fetch';
|
|
3
4
|
declare type Response = ReturnType<typeof nodeFetch>;
|
|
@@ -12,5 +13,11 @@ declare type Response = ReturnType<typeof nodeFetch>;
|
|
|
12
13
|
* @param init {RequestInit} An object containing any custom settings that you want to apply to the request
|
|
13
14
|
* @returns A promise that resolves with the response.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
export default function fetch(url: RequestInfo, init?: RequestInit): Response;
|
|
17
|
+
/**
|
|
18
|
+
* A fetch function to use with Shopify services. The function ensures the right
|
|
19
|
+
* TLS configuragion is used based on the environment in which the service is running
|
|
20
|
+
* (e.g. spin)
|
|
21
|
+
*/
|
|
22
|
+
export declare function shopifyFetch(service: Service, url: RequestInfo, init?: RequestInit): Response;
|
|
23
|
+
export {};
|
package/dist/http/fetch.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { httpsAgent } from '../http.js';
|
|
1
2
|
import nodeFetch from 'node-fetch';
|
|
2
3
|
/**
|
|
3
4
|
* An interface that abstracts way node-fetch. When Node has built-in
|
|
@@ -10,9 +11,17 @@ import nodeFetch from 'node-fetch';
|
|
|
10
11
|
* @param init {RequestInit} An object containing any custom settings that you want to apply to the request
|
|
11
12
|
* @returns A promise that resolves with the response.
|
|
12
13
|
*/
|
|
13
|
-
async function fetch(url, init) {
|
|
14
|
+
export default async function fetch(url, init) {
|
|
14
15
|
const response = await nodeFetch(url, init);
|
|
15
16
|
return response;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A fetch function to use with Shopify services. The function ensures the right
|
|
20
|
+
* TLS configuragion is used based on the environment in which the service is running
|
|
21
|
+
* (e.g. spin)
|
|
22
|
+
*/
|
|
23
|
+
export async function shopifyFetch(service, url, init) {
|
|
24
|
+
const response = await nodeFetch(url, { ...init, agent: await httpsAgent(service) });
|
|
25
|
+
return response;
|
|
26
|
+
}
|
|
18
27
|
//# sourceMappingURL=fetch.js.map
|
package/dist/http/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACtE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB,EAAE,GAAgB,EAAE,IAAkB;IACvF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,EAAC,CAAC,CAAA;IAClF,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {Service} from '../network/service.js'\n\nimport {httpsAgent} from '../http.js'\nimport nodeFetch from 'node-fetch'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url {RequestInfo} This defines the resource that you wish to fetch.\n * @param init {RequestInit} An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nexport default async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. spin)\n */\nexport async function shopifyFetch(service: Service, url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, {...init, agent: await httpsAgent(service)})\n return response\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Service } from '../network/service.js';
|
|
2
|
+
import { GraphQLClient } from 'graphql-request';
|
|
3
|
+
interface GraphqlClientOptions {
|
|
4
|
+
url: string;
|
|
5
|
+
service: Service;
|
|
6
|
+
headers: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a GraphQLClient instance with the right HTTPs agent baed on the service
|
|
12
|
+
* the client will interact with.
|
|
13
|
+
*/
|
|
14
|
+
export declare function graphqlClient(options: GraphqlClientOptions): Promise<GraphQLClient>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { httpsAgent } from '../http.js';
|
|
2
|
+
import { GraphQLClient } from 'graphql-request';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a GraphQLClient instance with the right HTTPs agent baed on the service
|
|
5
|
+
* the client will interact with.
|
|
6
|
+
*/
|
|
7
|
+
export async function graphqlClient(options) {
|
|
8
|
+
const clientOptions = { agent: await httpsAgent(options.service), headers: options.headers };
|
|
9
|
+
const client = new GraphQLClient(options.url, clientOptions);
|
|
10
|
+
return client;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/http/graphql.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAQ7C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,aAAa,GAAG,EAAC,KAAK,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAA;IAC1F,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAC5D,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {Service} from '../network/service.js'\nimport {httpsAgent} from '../http.js'\nimport {GraphQLClient} from 'graphql-request'\n\ninterface GraphqlClientOptions {\n url: string\n service: Service\n headers: {[key: string]: string}\n}\n\n/**\n * Creates a GraphQLClient instance with the right HTTPs agent baed on the service\n * the client will interact with.\n */\nexport async function graphqlClient(options: GraphqlClientOptions) {\n const clientOptions = {agent: await httpsAgent(options.service), headers: options.headers}\n const client = new GraphQLClient(options.url, clientOptions)\n return client\n}\n"]}
|
package/dist/http.d.ts
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Service } from './network/service.js';
|
|
3
|
+
import https from 'https';
|
|
1
4
|
export { default as fetch } from './http/fetch.js';
|
|
5
|
+
export { shopifyFetch } from './http/fetch.js';
|
|
2
6
|
export { default as formData } from './http/formdata.js';
|
|
7
|
+
/**
|
|
8
|
+
* This utility function returns the https.Agent to use for a given service. The agent
|
|
9
|
+
* includes the right configuration based on the service's environment. For example,
|
|
10
|
+
* if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
|
|
11
|
+
* set to false
|
|
12
|
+
*/
|
|
13
|
+
export declare function httpsAgent(service: Service): Promise<https.Agent>;
|
|
14
|
+
/**
|
|
15
|
+
* Spin stores the CA certificate in the keychain and it should be used when sending HTTP
|
|
16
|
+
* requests to Spin instances. However, Node doesn't read certificates from the Keychain
|
|
17
|
+
* by default, which leads to Shopifolks running into issues that they workaround by setting the
|
|
18
|
+
* NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
|
|
19
|
+
* requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
|
|
20
|
+
* This utility function allows controlling the behavior in a per-service level by returning
|
|
21
|
+
* the value of for the "rejectUnauthorized" attribute that's used in the https agent.
|
|
22
|
+
*
|
|
23
|
+
* @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether
|
|
24
|
+
* unauthorized requests should be rejected or not.
|
|
25
|
+
*/
|
|
26
|
+
export declare function shouldRejectUnauthorizedRequests(service: Service): Promise<boolean>;
|
package/dist/http.js
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
import { environmentForService } from './environment/service.js';
|
|
2
|
+
import https from 'https';
|
|
1
3
|
export { default as fetch } from './http/fetch.js';
|
|
4
|
+
export { shopifyFetch } from './http/fetch.js';
|
|
2
5
|
export { default as formData } from './http/formdata.js';
|
|
6
|
+
/**
|
|
7
|
+
* This utility function returns the https.Agent to use for a given service. The agent
|
|
8
|
+
* includes the right configuration based on the service's environment. For example,
|
|
9
|
+
* if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
|
|
10
|
+
* set to false
|
|
11
|
+
*/
|
|
12
|
+
export async function httpsAgent(service) {
|
|
13
|
+
return new https.Agent({ rejectUnauthorized: await shouldRejectUnauthorizedRequests(service) });
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Spin stores the CA certificate in the keychain and it should be used when sending HTTP
|
|
17
|
+
* requests to Spin instances. However, Node doesn't read certificates from the Keychain
|
|
18
|
+
* by default, which leads to Shopifolks running into issues that they workaround by setting the
|
|
19
|
+
* NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
|
|
20
|
+
* requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
|
|
21
|
+
* This utility function allows controlling the behavior in a per-service level by returning
|
|
22
|
+
* the value of for the "rejectUnauthorized" attribute that's used in the https agent.
|
|
23
|
+
*
|
|
24
|
+
* @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether
|
|
25
|
+
* unauthorized requests should be rejected or not.
|
|
26
|
+
*/
|
|
27
|
+
export async function shouldRejectUnauthorizedRequests(service) {
|
|
28
|
+
return (await environmentForService(service)) !== 'spin';
|
|
29
|
+
}
|
|
3
30
|
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAgB;IAC/C,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,kBAAkB,EAAE,MAAM,gCAAgC,CAAC,OAAO,CAAC,EAAC,CAAC,CAAA;AAC/F,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,OAAgB;IACrE,OAAO,CAAC,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC,KAAK,MAAM,CAAA;AAC1D,CAAC","sourcesContent":["import {Service} from './network/service.js'\nimport {environmentForService} from './environment/service.js'\nimport https from 'https'\n\nexport {default as fetch} from './http/fetch.js'\nexport {shopifyFetch} from './http/fetch.js'\nexport {default as formData} from './http/formdata.js'\n\n/**\n * This utility function returns the https.Agent to use for a given service. The agent\n * includes the right configuration based on the service's environment. For example,\n * if the service is running in a Spin environment, the attribute \"rejectUnauthorized\" is\n * set to false\n */\nexport async function httpsAgent(service: Service) {\n return new https.Agent({rejectUnauthorized: await shouldRejectUnauthorizedRequests(service)})\n}\n\n/**\n * Spin stores the CA certificate in the keychain and it should be used when sending HTTP\n * requests to Spin instances. However, Node doesn't read certificates from the Keychain\n * by default, which leads to Shopifolks running into issues that they workaround by setting the\n * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP\n * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)\n * This utility function allows controlling the behavior in a per-service level by returning\n * the value of for the \"rejectUnauthorized\" attribute that's used in the https agent.\n *\n * @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether\n * unauthorized requests should be rejected or not.\n */\nexport async function shouldRejectUnauthorizedRequests(service: Service): Promise<boolean> {\n return (await environmentForService(service)) !== 'spin'\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/network/service.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,4BAAa,CAAA;AACf,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB","sourcesContent":["/**\n * Enum for the differnet APIs the CLI can interact with.\n * @readonly\n * @enum {number}\n */\nexport type Service = 'shopify' | '
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/network/service.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,4BAAa,CAAA;AACf,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB","sourcesContent":["/**\n * Enum for the differnet APIs the CLI can interact with.\n * @readonly\n * @enum {number}\n */\nexport type Service = 'shopify' | 'partners' | 'identity'\n\n/**\n * Enum that represents the environment to use for a given service.\n * @readonly\n * @enum {number}\n */\nexport enum Environment {\n Local = 'local',\n Production = 'production',\n Spin = 'spin',\n}\n"]}
|
package/dist/node/archiver.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* It zips a directory.
|
|
2
|
+
* It zips a directory normalizing the paths to be forward-slash. Note that unzipping
|
|
3
|
+
* the zip generated by this function from a Windows environment won't work because paths
|
|
4
|
+
* need to be made backward-slash.
|
|
5
|
+
*
|
|
3
6
|
* @param inputDirectory {string} The absolute path to the directory to be zipped.
|
|
4
7
|
* @param outputZipPath {string} The absolute path to the output zip file.
|
|
5
8
|
*/
|
package/dist/node/archiver.js
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { debug, content, token } from '../output.js';
|
|
2
|
-
import {
|
|
2
|
+
import { glob, relative as relativePath } from '../path.js';
|
|
3
|
+
import archiver from 'archiver';
|
|
4
|
+
import { createWriteStream } from 'node:fs';
|
|
3
5
|
/**
|
|
4
|
-
* It zips a directory.
|
|
6
|
+
* It zips a directory normalizing the paths to be forward-slash. Note that unzipping
|
|
7
|
+
* the zip generated by this function from a Windows environment won't work because paths
|
|
8
|
+
* need to be made backward-slash.
|
|
9
|
+
*
|
|
5
10
|
* @param inputDirectory {string} The absolute path to the directory to be zipped.
|
|
6
11
|
* @param outputZipPath {string} The absolute path to the output zip file.
|
|
7
12
|
*/
|
|
8
13
|
export async function zip(inputDirectory, outputZipPath) {
|
|
9
14
|
debug(content `Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
reject(error);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
resolve();
|
|
20
|
-
}
|
|
15
|
+
const pathsToZip = await glob('**/*', { cwd: inputDirectory, absolute: true, dot: true, followSymbolicLinks: false });
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const archive = archiver('zip');
|
|
18
|
+
const output = createWriteStream(outputZipPath);
|
|
19
|
+
output.on('close', function () {
|
|
20
|
+
resolve();
|
|
21
21
|
});
|
|
22
|
+
archive.on('error', function (error) {
|
|
23
|
+
reject(error);
|
|
24
|
+
});
|
|
25
|
+
archive.pipe(output);
|
|
26
|
+
for (const filePath of pathsToZip) {
|
|
27
|
+
const fileRelativePath = relativePath(inputDirectory, filePath);
|
|
28
|
+
archive.file(filePath, { name: fileRelativePath });
|
|
29
|
+
}
|
|
30
|
+
archive.finalize();
|
|
22
31
|
});
|
|
23
32
|
}
|
|
24
33
|
//# sourceMappingURL=archiver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../src/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAClD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../src/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAClD,OAAO,EAAC,IAAI,EAAE,QAAQ,IAAI,YAAY,EAAC,MAAM,YAAY,CAAA;AACzD,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAA;AACzC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,cAAsB,EAAE,aAAqB;IACrE,KAAK,CAAC,OAAO,CAAA,WAAW,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IACvF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,EAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAC,CAAC,CAAA;IACnH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC/B,MAAM,MAAM,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAA;QAE/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE;YACjB,OAAO,EAAE,CAAA;QACX,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK;YACjC,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpB,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YACjC,MAAM,gBAAgB,GAAG,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;YAC/D,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC,CAAA;SACjD;QAED,OAAO,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {debug, content, token} from '../output.js'\nimport {glob, relative as relativePath} from '../path.js'\nimport archiver from 'archiver'\nimport {createWriteStream} from 'node:fs'\n/**\n * It zips a directory normalizing the paths to be forward-slash. Note that unzipping\n * the zip generated by this function from a Windows environment won't work because paths\n * need to be made backward-slash.\n *\n * @param inputDirectory {string} The absolute path to the directory to be zipped.\n * @param outputZipPath {string} The absolute path to the output zip file.\n */\nexport async function zip(inputDirectory: string, outputZipPath: string): Promise<void> {\n debug(content`Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`)\n const pathsToZip = await glob('**/*', {cwd: inputDirectory, absolute: true, dot: true, followSymbolicLinks: false})\n return new Promise((resolve, reject) => {\n const archive = archiver('zip')\n const output = createWriteStream(outputZipPath)\n\n output.on('close', function () {\n resolve()\n })\n archive.on('error', function (error) {\n reject(error)\n })\n archive.pipe(output)\n\n for (const filePath of pathsToZip) {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n archive.file(filePath, {name: fileRelativePath})\n }\n\n archive.finalize()\n })\n}\n"]}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { errorHandler } from './error-handler.js';
|
|
1
|
+
import { errorHandler, registerCleanBugsnagErrorsFromWithinPlugins } from './error-handler.js';
|
|
2
|
+
import { isDebug } from '../environment/local.js';
|
|
2
3
|
import { Command } from '@oclif/core';
|
|
3
4
|
// eslint-disable-next-line import/no-anonymous-default-export
|
|
4
5
|
export default class extends Command {
|
|
5
6
|
async catch(error) {
|
|
6
7
|
errorHandler(error);
|
|
7
8
|
}
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
async init() {
|
|
11
|
+
if (!isDebug()) {
|
|
12
|
+
// This function runs just prior to `run`
|
|
13
|
+
registerCleanBugsnagErrorsFromWithinPlugins(this.config.plugins);
|
|
14
|
+
}
|
|
15
|
+
return super.init();
|
|
16
|
+
}
|
|
8
17
|
}
|
|
9
18
|
//# sourceMappingURL=base-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AAEnC,8DAA8D;AAC9D,MAAM,CAAC,OAAO,MAAgB,SAAQ,OAAO;IAC3C,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,YAAY,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC;CACF","sourcesContent":["import {errorHandler} from './error-handler.js'\nimport {Command} from '@oclif/core'\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default abstract class extends Command {\n async catch(error: Error & {exitCode?: number | undefined}) {\n errorHandler(error)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AAEnC,8DAA8D;AAC9D,MAAM,CAAC,OAAO,MAAgB,SAAQ,OAAO;IAC3C,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,YAAY,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC;IAED,8DAA8D;IACpD,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,OAAO,EAAE,EAAE;YACd,yCAAyC;YACzC,2CAA2C,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;SACjE;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;IACrB,CAAC;CACF","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {isDebug} from '../environment/local.js'\nimport {Command} from '@oclif/core'\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default abstract class extends Command {\n async catch(error: Error & {exitCode?: number | undefined}) {\n errorHandler(error)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n if (!isDebug()) {\n // This function runs just prior to `run`\n registerCleanBugsnagErrorsFromWithinPlugins(this.config.plugins)\n }\n return super.init()\n }\n}\n"]}
|
package/dist/node/cli.d.ts
CHANGED
package/dist/node/cli.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// CLI
|
|
2
2
|
import { findUpAndReadPackageJson } from './node-package-manager.js';
|
|
3
3
|
import { errorHandler } from './error-handler.js';
|
|
4
|
-
import { initializeCliKitStore } from '../store.js';
|
|
5
|
-
import { initiateLogging } from '../output.js';
|
|
6
4
|
import { isDebug } from '../environment/local.js';
|
|
7
5
|
import constants, { bugsnagApiKey } from '../constants.js';
|
|
8
6
|
import { moduleDirectory } from '../path.js';
|
|
@@ -14,8 +12,6 @@ import Bugsnag from '@bugsnag/js';
|
|
|
14
12
|
* @param module {RunCLIOptions} Options.
|
|
15
13
|
*/
|
|
16
14
|
export async function runCLI(options) {
|
|
17
|
-
await initializeCliKitStore();
|
|
18
|
-
initiateLogging({ filename: options.logFilename });
|
|
19
15
|
if (isDebug()) {
|
|
20
16
|
settings.debug = true;
|
|
21
17
|
}
|
package/dist/node/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,MAAM;AACN,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,MAAM;AACN,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAA;AAC/C,OAA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AM,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,yBAAyB,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACtG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;KAC1C;IACD,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["// CLI\nimport {findUpAndReadPackageJson} from './node-package-manager.js'\nimport {errorHandler} from './error-handler.js'\nimport {isDebug} from '../environment/local.js'\nimport constants, {bugsnagApiKey} from '../constants.js'\nimport {moduleDirectory} from '../path.js'\nimport {run, settings, flush} from '@oclif/core'\nimport Bugsnag from '@bugsnag/js'\n\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param module {RunCLIOptions} Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n if (isDebug()) {\n settings.debug = true\n } else {\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n }\n\n run(undefined, options.moduleURL).then(flush).catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n * @param options\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport default runCLI\n"]}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
import { Interfaces } from '@oclif/core';
|
|
1
2
|
export declare function errorHandler(error: Error & {
|
|
2
3
|
exitCode?: number | undefined;
|
|
3
4
|
}): Promise<never> | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* If the given file path comes from within a plugin, return the relative path, plus the plugin name.
|
|
7
|
+
*
|
|
8
|
+
* This gives us very consistent paths for errors thrown from plugin code.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare function cleanStackFrameFilePath({ currentFilePath, projectRoot, pluginLocations, }: {
|
|
12
|
+
currentFilePath: string;
|
|
13
|
+
projectRoot: string;
|
|
14
|
+
pluginLocations: {
|
|
15
|
+
name: string;
|
|
16
|
+
pluginPath: string;
|
|
17
|
+
}[];
|
|
18
|
+
}): string;
|
|
19
|
+
/**
|
|
20
|
+
* Register a Bugsnag error listener to clean up stack traces for errors within plugin code.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare function registerCleanBugsnagErrorsFromWithinPlugins(plugins: Interfaces.Plugin[]): Promise<void>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { AbortSilent, CancelExecution, mapper as errorMapper, shouldReport as shouldReportError, handler, } from '../error.js';
|
|
1
|
+
import { AbortSilent, CancelExecution, mapper as errorMapper, shouldReport as shouldReportError, handler, cleanSingleStackTracePath, } from '../error.js';
|
|
2
2
|
import { info } from '../output.js';
|
|
3
3
|
import { reportEvent } from '../analytics.js';
|
|
4
|
-
import
|
|
4
|
+
import * as path from '../path.js';
|
|
5
5
|
import { settings } from '@oclif/core';
|
|
6
6
|
import StackTracey from 'stacktracey';
|
|
7
7
|
import Bugsnag from '@bugsnag/js';
|
|
8
|
+
import { realpath } from 'fs/promises';
|
|
8
9
|
export function errorHandler(error) {
|
|
9
10
|
if (error instanceof CancelExecution) {
|
|
10
11
|
if (error.message && error.message !== '') {
|
|
@@ -57,7 +58,7 @@ const reportError = async (error) => {
|
|
|
57
58
|
const formattedStacktrace = new StackTracey(stacktrace ?? '')
|
|
58
59
|
.clean()
|
|
59
60
|
.items.map((item) => {
|
|
60
|
-
const filePath =
|
|
61
|
+
const filePath = cleanSingleStackTracePath(item.file);
|
|
61
62
|
return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
|
|
62
63
|
})
|
|
63
64
|
.join('\n');
|
|
@@ -76,4 +77,40 @@ const reportError = async (error) => {
|
|
|
76
77
|
}
|
|
77
78
|
return reportableError;
|
|
78
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* If the given file path comes from within a plugin, return the relative path, plus the plugin name.
|
|
82
|
+
*
|
|
83
|
+
* This gives us very consistent paths for errors thrown from plugin code.
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
export function cleanStackFrameFilePath({ currentFilePath, projectRoot, pluginLocations, }) {
|
|
87
|
+
const fullLocation = path.isAbsolute(currentFilePath) ? currentFilePath : path.join(projectRoot, currentFilePath);
|
|
88
|
+
const matchingPluginPath = pluginLocations.filter(({ pluginPath }) => fullLocation.indexOf(pluginPath) === 0)[0];
|
|
89
|
+
if (matchingPluginPath !== undefined) {
|
|
90
|
+
// the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )
|
|
91
|
+
return path.join(matchingPluginPath.name, path.relative(matchingPluginPath.pluginPath, fullLocation));
|
|
92
|
+
}
|
|
93
|
+
return currentFilePath;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Register a Bugsnag error listener to clean up stack traces for errors within plugin code.
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
export async function registerCleanBugsnagErrorsFromWithinPlugins(plugins) {
|
|
100
|
+
// Bugsnag have their own plug-ins that use this private field
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
const bugsnagConfigProjectRoot = Bugsnag?._client?._config?.projectRoot ?? process.cwd();
|
|
103
|
+
const projectRoot = path.normalize(bugsnagConfigProjectRoot);
|
|
104
|
+
const pluginLocations = await Promise.all(plugins.map(async (plugin) => {
|
|
105
|
+
const followSymlinks = await realpath(plugin.root);
|
|
106
|
+
return { name: plugin.name, pluginPath: path.normalize(followSymlinks) };
|
|
107
|
+
}));
|
|
108
|
+
Bugsnag.addOnError((event) => {
|
|
109
|
+
event.errors.forEach((error) => {
|
|
110
|
+
error.stacktrace.forEach((stackFrame) => {
|
|
111
|
+
stackFrame.file = cleanStackFrameFilePath({ currentFilePath: stackFrame.file, projectRoot, pluginLocations });
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
79
116
|
//# sourceMappingURL=error-handler.js.map
|