@shopify/cli-kit 3.12.0 → 3.13.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 +19 -0
- package/dist/analytics.js +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/api/graphql/create_app.d.ts +1 -0
- package/dist/api/graphql/create_app.js +1 -0
- package/dist/api/graphql/create_app.js.map +1 -1
- package/dist/api/graphql/find_app.d.ts +1 -0
- package/dist/api/graphql/find_app.js +1 -0
- package/dist/api/graphql/find_app.js.map +1 -1
- package/dist/api/graphql/find_org.d.ts +1 -0
- package/dist/api/graphql/find_org.js +1 -0
- package/dist/api/graphql/find_org.js.map +1 -1
- package/dist/api.d.ts +2 -1
- package/dist/api.js +2 -1
- package/dist/api.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/file.d.ts +3 -0
- package/dist/file.js +3 -0
- package/dist/file.js.map +1 -1
- package/dist/git.d.ts +20 -0
- package/dist/git.js +53 -0
- package/dist/git.js.map +1 -1
- package/dist/http.d.ts +1 -0
- package/dist/http.js +1 -0
- package/dist/http.js.map +1 -1
- package/dist/node/cli.d.ts +6 -0
- package/dist/node/cli.js +38 -12
- package/dist/node/cli.js.map +1 -1
- package/dist/node/ruby.d.ts +2 -1
- package/dist/node/ruby.js +3 -2
- package/dist/node/ruby.js.map +1 -1
- package/dist/path.d.ts +2 -2
- package/dist/path.js +2 -2
- package/dist/path.js.map +1 -1
- package/dist/session/store.js +2 -1
- package/dist/session/store.js.map +1 -1
- package/dist/store.d.ts +5 -0
- package/dist/store.js +10 -1
- package/dist/store.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/inquirer/autocomplete.js +0 -3
- package/dist/ui/inquirer/autocomplete.js.map +1 -1
- package/dist/ui.d.ts +2 -2
- package/dist/ui.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @shopify/cli-kit
|
|
2
2
|
|
|
3
|
+
## 3.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a225e415: - cli-kit:
|
|
8
|
+
- Added additional Git functionality for commits, generating .gitignore templates, and ensuring commands are run in a Git project.
|
|
9
|
+
- Added new Oxygen service type for interacting with the Oyxgen service
|
|
10
|
+
- New method for creating readable file streams
|
|
11
|
+
- create-hydrogen
|
|
12
|
+
- Added support for initializing a local Git repository when you create a new Hydrogen project
|
|
13
|
+
- 5336b01f: Added support for extension development server to pass permissions metadata about the parent app to extension host systems
|
|
14
|
+
- 2239cad9: - `@shopify/cli-kit` - Add support to partners tokens in the `execCLI2` function
|
|
15
|
+
- `@shopify/app` - Add support to theme app extensions in the `app dev` command
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- a979c0de: Avoid the loosing of terminal cursor when using crtl+c with and active list prompt
|
|
20
|
+
- afa808cb: The overriden command name is correctly used
|
|
21
|
+
|
|
3
22
|
## 3.12.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/dist/analytics.js
CHANGED
|
@@ -9,7 +9,7 @@ import { fanoutHooks } from './plugins.js';
|
|
|
9
9
|
import { packageManagerUsedForCreating } from './node/node-package-manager.js';
|
|
10
10
|
export const start = async ({ command, args, currentTime = new Date().getTime(), commandClass }) => {
|
|
11
11
|
let startCommand = command;
|
|
12
|
-
if (commandClass && Object.prototype.hasOwnProperty.call(
|
|
12
|
+
if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsNameOverride')) {
|
|
13
13
|
startCommand = commandClass.analyticsNameOverride() ?? command;
|
|
14
14
|
}
|
|
15
15
|
await metadata.addSensitive(() => ({
|
package/dist/analytics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,K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O;QACL,KAAK,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE;QAC5B,MAAM,EAAE,UAAU,CAAC,IAAI;QACvB,eAAe,EAAE,UAAU,CAAC,IAAI;QAChC,+BAA+B,EAAE,WAAW,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM;QAC7E,4BAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;QAC5D,SAAS,EAAE,MAAM,CAAC,KAAK;QACvB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,cAAc,EAAE;KAChD,CAAA;AACH,CAAC","sourcesContent":["import * as environment from './environment.js'\nimport {platformAndArch} from './os.js'\nimport {version as rubyVersion} from './node/ruby.js'\nimport {content, debug, token} from './output.js'\nimport constants from './constants.js'\nimport * as metadata from './metadata.js'\nimport {publishEvent, MONORAIL_COMMAND_TOPIC} from './monorail.js'\nimport {fanoutHooks} from './plugins.js'\nimport {packageManagerUsedForCreating} from './node/node-package-manager.js'\nimport BaseCommand from './node/base-command.js'\nimport {Interfaces} from '@oclif/core'\n\ninterface StartOptions {\n command: string\n args: string[]\n currentTime?: number\n commandClass?: Interfaces.Command.Class | typeof BaseCommand\n}\n\nexport const start = async ({command, args, currentTime = new Date().getTime(), commandClass}: StartOptions) => {\n let startCommand: string = command\n if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsNameOverride')) {\n startCommand = (commandClass as typeof BaseCommand).analyticsNameOverride() ?? command\n }\n\n await metadata.addSensitive(() => ({\n commandStartOptions: {\n startTime: currentTime,\n startCommand,\n startArgs: args,\n },\n }))\n\n await metadata.addPublic(() => ({\n cmd_all_launcher: packageManagerUsedForCreating(),\n cmd_all_plugin: commandClass?.plugin?.name,\n }))\n}\n\ninterface ReportEventOptions {\n config: Interfaces.Config\n errorMessage?: string\n}\n\n/**\n * Report an analytics event, sending it off to Monorail -- Shopify's internal analytics service.\n *\n * The payload for an event includes both generic data, and data gathered from installed plug-ins.\n *\n */\nexport async function reportEvent(options: ReportEventOptions) {\n try {\n const payload = await buildPayload(options)\n if (payload === undefined) {\n // Nothing to log\n return\n }\n if (!environment.local.alwaysLogAnalytics() && environment.local.analyticsDisabled()) {\n debug(content`Skipping command analytics, payload: ${token.json(payload)}`)\n return\n }\n const response = await publishEvent(MONORAIL_COMMAND_TOPIC, payload.public, payload.sensitive)\n if (response.type === 'error') {\n debug(response.message)\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n }\n}\n\nconst buildPayload = async ({config, errorMessage}: ReportEventOptions) => {\n const {commandStartOptions, ...sensitiveMetadata} = metadata.getAllSensitive()\n if (commandStartOptions === undefined) {\n debug('Unable to log analytics event - no information on executed command')\n return\n }\n const {startCommand, startArgs, startTime} = commandStartOptions\n const currentTime = new Date().getTime()\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n const sensitivePluginData = await fanoutHooks(config, 'sensitive_command_metadata', {})\n\n const environmentData = getEnvironmentData(config)\n\n return {\n public: {\n command: startCommand,\n time_start: startTime,\n time_end: currentTime,\n total_time: currentTime - startTime,\n success: errorMessage === undefined,\n cli_version: await constants.versions.cliKit(),\n ruby_version: (await rubyVersion()) || '',\n node_version: process.version.replace('v', ''),\n is_employee: await environment.local.isShopify(),\n ...environmentData,\n ...appPublic,\n ...metadata.getAllPublic(),\n },\n sensitive: {\n args: startArgs.join(' '),\n error_message: errorMessage,\n metadata: JSON.stringify({\n ...sensitiveMetadata,\n extraPublic: {\n ...otherPluginsPublic,\n },\n extraSensitive: sensitivePluginData,\n }),\n },\n }\n}\n\nexport function getEnvironmentData(config: Interfaces.Config) {\n const ciPlatform = environment.local.ciPlatform()\n\n const pluginNames = config.plugins\n .map((plugin) => plugin.name)\n .sort()\n .filter((plugin) => !plugin.startsWith('@oclif/'))\n const shopifyPlugins = pluginNames.filter((plugin) => plugin.startsWith('@shopify/'))\n\n const {platform, arch} = platformAndArch()\n\n return {\n uname: `${platform} ${arch}`,\n env_ci: ciPlatform.isCI,\n env_ci_platform: ciPlatform.name,\n env_plugin_installed_any_custom: pluginNames.length !== shopifyPlugins.length,\n env_plugin_installed_shopify: JSON.stringify(shopifyPlugins),\n env_shell: config.shell,\n env_web_ide: environment.local.webIDEPlatform(),\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_app.js","sourceRoot":"","sources":["../../../src/api/graphql/create_app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"create_app.js","sourceRoot":"","sources":["../../../src/api/graphql/create_app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BhC,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const CreateAppQuery = gql`\n mutation AppCreate($org: Int!, $title: String!, $appUrl: Url!, $redir: [Url]!, $type: AppType) {\n appCreate(\n input: {\n organizationID: $org\n title: $title\n applicationUrl: $appUrl\n redirectUrlWhitelist: $redir\n appType: $type\n }\n ) {\n app {\n id\n apiKey\n title\n appType\n applicationUrl\n redirectUrlWhitelist\n apiSecretKeys {\n secret\n }\n appType\n grantedScopes\n }\n userErrors {\n field\n message\n }\n }\n }\n`\n\nexport interface CreateAppQueryVariables {\n org: number\n title: string\n appUrl: string\n redir: string[]\n type: string\n}\n\nexport interface CreateAppQuerySchema {\n appCreate: {\n app: {\n id: string\n apiKey: string\n title: string\n applicationUrl: string\n redirectUrlWhitelist: string[]\n organizationId: string\n apiSecretKeys: {\n secret: string\n }[]\n appType: string\n grantedScopes: string[]\n }\n userErrors: {\n field: string[]\n message: string\n }[]\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find_app.js","sourceRoot":"","sources":["../../../src/api/graphql/find_app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"find_app.js","sourceRoot":"","sources":["../../../src/api/graphql/find_app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;CAc9B,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const FindAppQuery = gql`\n query FindApp($apiKey: String!) {\n app(apiKey: $apiKey) {\n id\n title\n apiKey\n organizationId\n apiSecretKeys {\n secret\n }\n appType\n grantedScopes\n }\n }\n`\n\nexport interface FindAppQuerySchema {\n app: {\n id: string\n title: string\n apiKey: string\n organizationId: string\n apiSecretKeys: {\n secret: string\n }[]\n appType: string\n grantedScopes: string[]\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find_org.js","sourceRoot":"","sources":["../../../src/api/graphql/find_org.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"find_org.js","sourceRoot":"","sources":["../../../src/api/graphql/find_org.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;CAwBvC,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const FindOrganizationQuery = gql`\n query FindOrganization($id: ID!) {\n organizations(id: $id, first: 1) {\n nodes {\n id\n businessName\n website\n appsNext\n apps(first: 100) {\n nodes {\n id\n title\n apiKey\n organizationId\n apiSecretKeys {\n secret\n }\n appType\n grantedScopes\n }\n }\n }\n }\n }\n`\n\nexport interface FindOrganizationQuerySchema {\n organizations: {\n nodes: {\n id: string\n businessName: string\n website: string\n appsNext: boolean\n apps: {\n nodes: {\n id: string\n title: string\n apiKey: string\n organizationId: string\n apiSecretKeys: {\n secret: string\n }[]\n appType: string\n grantedScopes: string[]\n }[]\n }\n }[]\n }\n}\n"]}
|
package/dist/api.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import * as admin from './api/admin.js';
|
|
|
2
2
|
import * as partners from './api/partners.js';
|
|
3
3
|
import * as graphql from './api/graphql/index.js';
|
|
4
4
|
import * as identity from './api/identity.js';
|
|
5
|
-
|
|
5
|
+
import { buildHeaders } from './api/common.js';
|
|
6
|
+
export { admin, partners, graphql, identity, buildHeaders };
|
package/dist/api.js
CHANGED
|
@@ -2,5 +2,6 @@ import * as admin from './api/admin.js';
|
|
|
2
2
|
import * as partners from './api/partners.js';
|
|
3
3
|
import * as graphql from './api/graphql/index.js';
|
|
4
4
|
import * as identity from './api/identity.js';
|
|
5
|
-
|
|
5
|
+
import { buildHeaders } from './api/common.js';
|
|
6
|
+
export { admin, partners, graphql, identity, buildHeaders };
|
|
6
7
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAA","sourcesContent":["import * as admin from './api/admin.js'\nimport * as partners from './api/partners.js'\nimport * as graphql from './api/graphql/index.js'\nimport * as identity from './api/identity.js'\nimport {buildHeaders} from './api/common.js'\n\nexport {admin, partners, graphql, identity, buildHeaders}\n"]}
|
package/dist/constants.js
CHANGED
|
@@ -10,7 +10,7 @@ const cacheFolder = () => {
|
|
|
10
10
|
const constants = {
|
|
11
11
|
environmentVariables: {
|
|
12
12
|
unitTest: 'SHOPIFY_UNIT_TEST',
|
|
13
|
-
env: '
|
|
13
|
+
env: 'SHOPIFY_CLI_ENV',
|
|
14
14
|
serviceEnv: 'SHOPIFY_SERVICE_ENV',
|
|
15
15
|
runAsUser: 'SHOPIFY_RUN_AS_USER',
|
|
16
16
|
spinInstance: 'SPIN_INSTANCE',
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAA;AACjD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAA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MAAM,EAAE,sBAAsB;KAC/B;IACD,KAAK,EAAE;QACL,WAAW,EAAE;YACX,GAAG,EAAE,kBAAkB;SACxB;QACD,WAAW,EAAE;YACX,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,EAAE;oBACT,OAAO,WAAW,EAAE,CAAA;gBACtB,CAAC;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,GAAG,EAAE;wBACT,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAA;oBAC1C,CAAC;oBACD,QAAQ,EAAE,GAAG,EAAE;wBACb,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;oBACtD,CAAC;iBACF;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,OAAO,oBAAoB,CAAC,EAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC,CAAC,CAAA;QAC/D,CAAC;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,aAAa;KACvB;IACD,OAAO,EAAE;QACP,6BAA6B,EAAE,CAAC;KACjC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,eAAe,SAAS,CAAA","sourcesContent":["import {join as pathJoin} from './path.js'\nimport {findPackageVersionUp} from './version.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n unitTest: 'SHOPIFY_UNIT_TEST',\n env: 'SHOPIFY_CLI_ENV',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n spinInstance: 'SPIN_INSTANCE',\n spinWorkspace: 'SPIN_WORKSPACE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinHost: 'SPIN_HOST',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n // Variables to detect if the CLI is running in a cloud environment\n spin: 'SPIN',\n codespaces: 'CODESPACES',\n codespaceName: 'CODESPACE_NAME',\n gitpod: 'GITPOD_WORKSPACE_URL',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
|
package/dist/file.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import fs from 'fs-extra';
|
|
1
3
|
export declare function stripUp(path: string, strip: number): string;
|
|
2
4
|
/**
|
|
3
5
|
* Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.
|
|
@@ -43,6 +45,7 @@ export declare function mkTmpDir(): Promise<string>;
|
|
|
43
45
|
export declare function isDirectory(path: string): Promise<boolean>;
|
|
44
46
|
export declare function size(path: string): Promise<number>;
|
|
45
47
|
export declare function sizeSync(path: string): number;
|
|
48
|
+
export declare function createReadStream(path: string): fs.ReadStream;
|
|
46
49
|
/**
|
|
47
50
|
* Moves a file.
|
|
48
51
|
* @param src {string} File to be moved.
|
package/dist/file.js
CHANGED
|
@@ -123,6 +123,9 @@ export function sizeSync(path) {
|
|
|
123
123
|
debug(outputContent `Sync-getting the size of file file at ${token.path(path)}...`);
|
|
124
124
|
return fs.statSync(path).size;
|
|
125
125
|
}
|
|
126
|
+
export function createReadStream(path) {
|
|
127
|
+
return fs.createReadStream(path);
|
|
128
|
+
}
|
|
126
129
|
/**
|
|
127
130
|
* Moves a file.
|
|
128
131
|
* @param src {string} File to be moved.
|
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,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AACxC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,MAAM,uBAAuB,GAAY;IACvC,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,KAAK;CACrB,CAAA;AAED,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,KAAa;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7B,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM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GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAY;IACzD,IAAI;QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACjD,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAY;IACvC,IAAI;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 to 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\n/**\n * Given a path, it determines the actual path. This is useful when working\n * with paths that represent symlinks.\n * @param path {string} Path whose real path will be returned.\n * @returns\n */\nexport async function realpath(path: string): Promise<string> {\n return fs.promises.realpath(path)\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 function touchSync(path: string) {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n 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 function removeSync(path: string) {\n debug(outputContent`Sync-removing file at ${token.path(path)}...`)\n fs.removeSync(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":"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,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AACxC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,MAAM,uBAAuB,GAAY;IACvC,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,KAAK;CACrB,CAAA;AAED,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,KAAa;IACjD,M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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 to 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\n/**\n * Given a path, it determines the actual path. This is useful when working\n * with paths that represent symlinks.\n * @param path {string} Path whose real path will be returned.\n * @returns\n */\nexport async function realpath(path: string): Promise<string> {\n return fs.promises.realpath(path)\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 function touchSync(path: string) {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n 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 function removeSync(path: string) {\n debug(outputContent`Sync-removing file at ${token.path(path)}...`)\n fs.removeSync(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\nexport function createReadStream(path: string) {\n return fs.createReadStream(path)\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.d.ts
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
import { Abort } from './error.js';
|
|
2
|
+
import { DefaultLogFields, ListLogLine } from 'simple-git';
|
|
2
3
|
export declare const factory: import("simple-git").SimpleGitFactory;
|
|
3
4
|
export declare const GitNotPresentError: () => Abort;
|
|
5
|
+
export declare const OutsideGitDirectoryError: (directory: string) => Abort;
|
|
6
|
+
export declare const NoCommitError: () => Abort;
|
|
7
|
+
export declare const DetachedHeadError: () => Abort;
|
|
4
8
|
export declare function initializeRepository(directory: string): Promise<void>;
|
|
9
|
+
export interface GitIgnoreTemplate {
|
|
10
|
+
[section: string]: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createGitIgnore(directory: string, template: GitIgnoreTemplate): void;
|
|
5
13
|
export declare function downloadRepository({ repoUrl, destination, progressUpdater, shallow, }: {
|
|
6
14
|
repoUrl: string;
|
|
7
15
|
destination: string;
|
|
8
16
|
progressUpdater?: (statusString: string) => void;
|
|
9
17
|
shallow?: boolean;
|
|
10
18
|
}): Promise<void>;
|
|
19
|
+
export declare function getLatestCommit(directory?: string): Promise<DefaultLogFields & ListLogLine>;
|
|
20
|
+
export declare function addAll(directory?: string): Promise<void>;
|
|
21
|
+
export declare function commit(message: string, options?: {
|
|
22
|
+
directory?: string;
|
|
23
|
+
author?: string;
|
|
24
|
+
}): Promise<string>;
|
|
25
|
+
export declare function getHeadSymbolicRef(directory?: string): Promise<string>;
|
|
11
26
|
/**
|
|
12
27
|
* If "git" is not present in the environment it throws
|
|
13
28
|
* an abort error.
|
|
14
29
|
*/
|
|
15
30
|
export declare function ensurePresentOrAbort(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* If command run from outside a .git directory tree
|
|
33
|
+
* it throws an abort error.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ensureInsideGitDirectory(directory?: string): Promise<void>;
|
package/dist/git.js
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { Abort } from './error.js';
|
|
2
2
|
import { hasGit, isTerminalInteractive } from './environment/local.js';
|
|
3
3
|
import { content, token, debug } from './output.js';
|
|
4
|
+
import { appendSync } from './file.js';
|
|
4
5
|
import git from 'simple-git';
|
|
5
6
|
export const factory = git;
|
|
6
7
|
export const GitNotPresentError = () => {
|
|
7
8
|
return new Abort(`Git is necessary in the environment to continue`, content `Install ${token.link('git', 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git')}`);
|
|
8
9
|
};
|
|
10
|
+
export const OutsideGitDirectoryError = (directory) => {
|
|
11
|
+
return new Abort(`${token.path(directory)} is not a Git directory`);
|
|
12
|
+
};
|
|
13
|
+
export const NoCommitError = () => {
|
|
14
|
+
return new Abort('Must have at least one commit to run command', content `Run ${token.genericShellCommand("git commit -m 'Initial commit'")} to create your first commit.`);
|
|
15
|
+
};
|
|
16
|
+
export const DetachedHeadError = () => {
|
|
17
|
+
return new Abort("Git HEAD can't be detached to run command", content `Run ${token.genericShellCommand('git checkout [branchName]')} to reattach HEAD or see git ${token.link('documentation', 'https://git-scm.com/book/en/v2/Git-Internals-Git-References')} for more details`);
|
|
18
|
+
};
|
|
9
19
|
export async function initializeRepository(directory) {
|
|
10
20
|
debug(content `Initializing git repository at ${token.path(directory)}...`);
|
|
11
21
|
await ensurePresentOrAbort();
|
|
12
22
|
await git(directory).init();
|
|
13
23
|
}
|
|
24
|
+
export function createGitIgnore(directory, template) {
|
|
25
|
+
debug(content `Creating .gitignore at ${token.path(directory)}...`);
|
|
26
|
+
const filePath = `${directory}/.gitignore`;
|
|
27
|
+
let fileContent = '';
|
|
28
|
+
for (const [section, lines] of Object.entries(template)) {
|
|
29
|
+
fileContent += `# ${section}\n`;
|
|
30
|
+
fileContent += `${lines.join('\n')}\n\n`;
|
|
31
|
+
}
|
|
32
|
+
appendSync(filePath, fileContent);
|
|
33
|
+
}
|
|
14
34
|
export async function downloadRepository({ repoUrl, destination, progressUpdater, shallow, }) {
|
|
15
35
|
debug(content `Git-cloning repository ${repoUrl} into ${token.path(destination)}...`);
|
|
16
36
|
await ensurePresentOrAbort();
|
|
@@ -43,6 +63,30 @@ export async function downloadRepository({ repoUrl, destination, progressUpdater
|
|
|
43
63
|
throw err;
|
|
44
64
|
}
|
|
45
65
|
}
|
|
66
|
+
export async function getLatestCommit(directory) {
|
|
67
|
+
const logs = await git({ baseDir: directory }).log({
|
|
68
|
+
maxCount: 1,
|
|
69
|
+
});
|
|
70
|
+
if (!logs.latest)
|
|
71
|
+
throw NoCommitError();
|
|
72
|
+
return logs.latest;
|
|
73
|
+
}
|
|
74
|
+
export async function addAll(directory) {
|
|
75
|
+
const simpleGit = git({ baseDir: directory });
|
|
76
|
+
await simpleGit.raw('add', '--all');
|
|
77
|
+
}
|
|
78
|
+
export async function commit(message, options) {
|
|
79
|
+
const simpleGit = git({ baseDir: options?.directory });
|
|
80
|
+
const commitOptions = options?.author ? { '--author': options.author } : undefined;
|
|
81
|
+
const result = await simpleGit.commit(message, commitOptions);
|
|
82
|
+
return result.commit;
|
|
83
|
+
}
|
|
84
|
+
export async function getHeadSymbolicRef(directory) {
|
|
85
|
+
const ref = await git({ baseDir: directory }).raw('symbolic-ref', '-q', 'HEAD');
|
|
86
|
+
if (!ref)
|
|
87
|
+
throw DetachedHeadError();
|
|
88
|
+
return ref.trim();
|
|
89
|
+
}
|
|
46
90
|
/**
|
|
47
91
|
* If "git" is not present in the environment it throws
|
|
48
92
|
* an abort error.
|
|
@@ -52,4 +96,13 @@ export async function ensurePresentOrAbort() {
|
|
|
52
96
|
throw GitNotPresentError();
|
|
53
97
|
}
|
|
54
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* If command run from outside a .git directory tree
|
|
101
|
+
* it throws an abort error.
|
|
102
|
+
*/
|
|
103
|
+
export async function ensureInsideGitDirectory(directory) {
|
|
104
|
+
if (!(await git({ baseDir: directory }).checkIsRepo())) {
|
|
105
|
+
throw OutsideGitDirectoryError(directory || process.cwd());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
55
108
|
//# sourceMappingURL=git.js.map
|
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,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AACpE,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wB,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;KAC3D;AACH,CAAC","sourcesContent":["import {Abort} from './error.js'\nimport {hasGit, isTerminalInteractive} from './environment/local.js'\nimport {content, token, debug} from './output.js'\nimport {appendSync} from './file.js'\nimport git, {TaskOptions, SimpleGitProgressEvent, DefaultLogFields, ListLogLine} 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 const OutsideGitDirectoryError = (directory: string) => {\n return new Abort(`${token.path(directory)} is not a Git directory`)\n}\n\nexport const NoCommitError = () => {\n return new Abort(\n 'Must have at least one commit to run command',\n content`Run ${token.genericShellCommand(\"git commit -m 'Initial commit'\")} to create your first commit.`,\n )\n}\n\nexport const DetachedHeadError = () => {\n return new Abort(\n \"Git HEAD can't be detached to run command\",\n content`Run ${token.genericShellCommand('git checkout [branchName]')} to reattach HEAD or see git ${token.link(\n 'documentation',\n 'https://git-scm.com/book/en/v2/Git-Internals-Git-References',\n )} for more details`,\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 interface GitIgnoreTemplate {\n [section: string]: string[]\n}\nexport function createGitIgnore(directory: string, template: GitIgnoreTemplate): void {\n debug(content`Creating .gitignore at ${token.path(directory)}...`)\n const filePath = `${directory}/.gitignore`\n\n let fileContent = ''\n for (const [section, lines] of Object.entries(template)) {\n fileContent += `# ${section}\\n`\n fileContent += `${lines.join('\\n')}\\n\\n`\n }\n\n appendSync(filePath, fileContent)\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 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\nexport async function getLatestCommit(directory?: string): Promise<DefaultLogFields & ListLogLine> {\n const logs = await git({baseDir: directory}).log({\n maxCount: 1,\n })\n if (!logs.latest) throw NoCommitError()\n return logs.latest\n}\n\nexport async function addAll(directory?: string): Promise<void> {\n const simpleGit = git({baseDir: directory})\n await simpleGit.raw('add', '--all')\n}\n\nexport async function commit(message: string, options?: {directory?: string; author?: string}): Promise<string> {\n const simpleGit = git({baseDir: options?.directory})\n\n const commitOptions = options?.author ? {'--author': options.author} : undefined\n const result = await simpleGit.commit(message, commitOptions)\n\n return result.commit\n}\n\nexport async function getHeadSymbolicRef(directory?: string): Promise<string> {\n const ref = await git({baseDir: directory}).raw('symbolic-ref', '-q', 'HEAD')\n if (!ref) throw DetachedHeadError()\n return ref.trim()\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\n/**\n * If command run from outside a .git directory tree\n * it throws an abort error.\n */\nexport async function ensureInsideGitDirectory(directory?: string) {\n if (!(await git({baseDir: directory}).checkIsRepo())) {\n throw OutsideGitDirectoryError(directory || process.cwd())\n }\n}\n"]}
|
package/dist/http.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import https from 'https';
|
|
3
3
|
export { default as fetch } from './http/fetch.js';
|
|
4
|
+
export { graphqlClient } from './http/graphql.js';
|
|
4
5
|
export { shopifyFetch } from './http/fetch.js';
|
|
5
6
|
export { default as formData } from './http/formdata.js';
|
|
6
7
|
/**
|
package/dist/http.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { serviceEnvironment } from './environment/service.js';
|
|
2
2
|
import https from 'https';
|
|
3
3
|
export { default as fetch } from './http/fetch.js';
|
|
4
|
+
export { graphqlClient } from './http/graphql.js';
|
|
4
5
|
export { shopifyFetch } from './http/fetch.js';
|
|
5
6
|
export { default as formData } from './http/formdata.js';
|
|
6
7
|
/**
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAA;AAC3D,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;IAC9B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,kBAAkB,EAAE,MAAM,gCAAgC,EAAE,EAAC,CAAC,CAAA;AACxF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,CAAC,MAAM,kBAAkB,EAAE,CAAC,KAAK,MAAM,CAAA;AAChD,CAAC","sourcesContent":["import {serviceEnvironment} 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() {\n return new https.Agent({rejectUnauthorized: await shouldRejectUnauthorizedRequests()})\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(): Promise<boolean> {\n return (await serviceEnvironment()) !== 'spin'\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAC/C,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;IAC9B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,kBAAkB,EAAE,MAAM,gCAAgC,EAAE,EAAC,CAAC,CAAA;AACxF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,CAAC,MAAM,kBAAkB,EAAE,CAAC,KAAK,MAAM,CAAA;AAChD,CAAC","sourcesContent":["import {serviceEnvironment} from './environment/service.js'\nimport https from 'https'\n\nexport {default as fetch} from './http/fetch.js'\nexport {graphqlClient} from './http/graphql.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() {\n return new https.Agent({rejectUnauthorized: await shouldRejectUnauthorizedRequests()})\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(): Promise<boolean> {\n return (await serviceEnvironment()) !== 'spin'\n}\n"]}
|
package/dist/node/cli.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTANT NOTE: Imports in this module are dynamic to ensure that "setupEnvironmentVariables" can dynamically
|
|
3
|
+
* set the DEBUG environment variable before the 'debug' package sets up its configuration when modules
|
|
4
|
+
* are loaded statically.
|
|
5
|
+
*/
|
|
1
6
|
interface RunCLIOptions {
|
|
2
7
|
/** The value of import.meta.url of the CLI executable module */
|
|
3
8
|
moduleURL: string;
|
|
9
|
+
development: boolean;
|
|
4
10
|
}
|
|
5
11
|
/**
|
|
6
12
|
* A function that abstracts away setting up the environment and running
|
package/dist/node/cli.js
CHANGED
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTANT NOTE: Imports in this module are dynamic to ensure that "setupEnvironmentVariables" can dynamically
|
|
3
|
+
* set the DEBUG environment variable before the 'debug' package sets up its configuration when modules
|
|
4
|
+
* are loaded statically.
|
|
5
|
+
*/
|
|
6
|
+
function setupEnvironmentVariables(options) {
|
|
7
|
+
/**
|
|
8
|
+
* By setting DEBUG=* when --verbose is passed we are increasing the
|
|
9
|
+
* verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)
|
|
10
|
+
* for logging, and it's configured through the DEBUG= environment variable.
|
|
11
|
+
*/
|
|
12
|
+
if (process.argv.includes('--verbose')) {
|
|
13
|
+
process.env.DEBUG = process.env.DEBUG ?? '*';
|
|
14
|
+
}
|
|
15
|
+
if (options.development) {
|
|
16
|
+
process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
10
19
|
/**
|
|
11
20
|
* A function that abstracts away setting up the environment and running
|
|
12
21
|
* a CLI
|
|
13
22
|
* @param options {RunCLIOptions} Options.
|
|
14
23
|
*/
|
|
15
24
|
export async function runCLI(options) {
|
|
25
|
+
setupEnvironmentVariables(options);
|
|
26
|
+
/**
|
|
27
|
+
* These imports need to be dynamic because if they are static
|
|
28
|
+
* they are loaded before se set the DEBUG=* environment variable
|
|
29
|
+
* and therefore it has no effect.
|
|
30
|
+
*/
|
|
31
|
+
const { errorHandler } = await import('./error-handler.js');
|
|
32
|
+
const { isDevelopment } = await import('../environment/local.js');
|
|
33
|
+
const { run, settings, flush } = await import('@oclif/core');
|
|
16
34
|
if (isDevelopment()) {
|
|
17
35
|
settings.debug = true;
|
|
18
36
|
}
|
|
@@ -23,6 +41,9 @@ export async function runCLI(options) {
|
|
|
23
41
|
* @param options
|
|
24
42
|
*/
|
|
25
43
|
export async function runCreateCLI(options) {
|
|
44
|
+
setupEnvironmentVariables(options);
|
|
45
|
+
const { findUpAndReadPackageJson } = await import('./node-package-manager.js');
|
|
46
|
+
const { moduleDirectory } = await import('../path.js');
|
|
26
47
|
const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL));
|
|
27
48
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
49
|
const packageName = packageJson.content.name;
|
|
@@ -35,11 +56,15 @@ export async function runCreateCLI(options) {
|
|
|
35
56
|
await runCLI(options);
|
|
36
57
|
}
|
|
37
58
|
export async function useLocalCLIIfDetected(filepath) {
|
|
59
|
+
const { isTruthy } = await import('../environment/utilities.js');
|
|
60
|
+
const constants = await import('../constants.js');
|
|
61
|
+
const { join } = await import('../path.js');
|
|
62
|
+
const { exec } = await import('../system.js');
|
|
38
63
|
// Temporary flag while we test out this feature and ensure it won't break anything!
|
|
39
|
-
if (!isTruthy(process.env[constants.environmentVariables.enableCliRedirect]))
|
|
64
|
+
if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect]))
|
|
40
65
|
return false;
|
|
41
66
|
// Setting an env variable in the child process prevents accidental recursion.
|
|
42
|
-
if (isTruthy(process.env[constants.environmentVariables.skipCliRedirect]))
|
|
67
|
+
if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect]))
|
|
43
68
|
return false;
|
|
44
69
|
// If already running via package manager, we can assume it's running correctly already.
|
|
45
70
|
if (process.env.npm_config_user_agent)
|
|
@@ -53,7 +78,7 @@ export async function useLocalCLIIfDetected(filepath) {
|
|
|
53
78
|
try {
|
|
54
79
|
await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {
|
|
55
80
|
stdio: 'inherit',
|
|
56
|
-
env: { [constants.environmentVariables.skipCliRedirect]: '1' },
|
|
81
|
+
env: { [constants.default.environmentVariables.skipCliRedirect]: '1' },
|
|
57
82
|
});
|
|
58
83
|
// eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any
|
|
59
84
|
}
|
|
@@ -63,6 +88,7 @@ export async function useLocalCLIIfDetected(filepath) {
|
|
|
63
88
|
return true;
|
|
64
89
|
}
|
|
65
90
|
async function localCliPackage() {
|
|
91
|
+
const { captureOutput } = await import('../system.js');
|
|
66
92
|
let npmListOutput = '';
|
|
67
93
|
let localShopifyCLI = {};
|
|
68
94
|
try {
|