@shopify/oxygen-cli 4.0.1-unstable.202401191555.0 → 4.0.1-unstable.202401192311.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5 -0
- package/README.md +39 -35
- package/dist/utils/utils.js +1 -1
- package/dist/utils/utils.js.map +1 -1
- package/oclif.manifest.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -10,6 +10,10 @@
|
|
10
10
|
|
11
11
|
If you need your deployment to be accessible without authentication (e.g. end-to-end testing frameworks) you should use `--generateAuthBypassToken`.
|
12
12
|
|
13
|
+
### Minor Changes
|
14
|
+
|
15
|
+
- 5528ab6: Default to npm build instead of yarn
|
16
|
+
|
13
17
|
### Patch Changes
|
14
18
|
|
15
19
|
- e7db80e: Add `--defaultEnvironment` flag
|
@@ -19,6 +23,7 @@
|
|
19
23
|
- 2e2ec1e: Update vitest from 1.2.0 to 1.2.1
|
20
24
|
- 9fde899: Update oclif from 4.3.4 to 4.3.5
|
21
25
|
- 6a82491: Update vite from 5.0.11 to 5.0.12
|
26
|
+
- 872891f: Update oclif from 4.3.5 to 4.3.6
|
22
27
|
|
23
28
|
## 3.1.8
|
24
29
|
|
package/README.md
CHANGED
@@ -6,61 +6,65 @@
|
|
6
6
|
|
7
7
|
The oxygen-cli can be run locally, or it can be used from within CI/CD environments such as Github Actions.
|
8
8
|
|
9
|
-
|
9
|
+
### Standalone
|
10
|
+
|
11
|
+
```sh
|
12
|
+
npm install -g @shopify/oxygen-cli
|
13
|
+
```
|
14
|
+
|
15
|
+
The CLI can then be activated using the command `oxygen-cli`.
|
16
|
+
|
17
|
+
### As a Shopify Plugin
|
10
18
|
|
11
19
|
You can also install oxygen-cli as plugin for [@shopify/cli](https://www.npmjs.com/package/@shopify/cli). When this is installed globally, running the following will install oxygen-cli:
|
12
20
|
|
13
|
-
```
|
21
|
+
```sh
|
14
22
|
shopify plugins install @shopify/oxygen-cli
|
15
23
|
```
|
16
24
|
|
17
25
|
The CLI will now expose its commands under `shopify oxygen`.
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
```
|
22
|
-
npm install -g @shopify/oxygen-cli
|
23
|
-
```
|
27
|
+
### Hydrogen
|
24
28
|
|
25
|
-
|
29
|
+
If you're building a Hydrogen storefront you'll want to use the [hydrogen-cli](https://www.npmjs.com/package/@shopify/hydrogen-cli) wrapper. This package should automatically be included as a dependency in your application. This is a convenience wrapper around `oxygen-cli` to use nomenclature and design patterns that Hydrogen developers will be more familiar with.
|
26
30
|
|
27
31
|
## Command overview
|
28
32
|
|
29
33
|
- `oxygen deploy` command initiates a deployment to Oxygen.
|
30
34
|
|
31
|
-
```
|
35
|
+
```sh
|
32
36
|
oxygen:deploy [options]
|
33
37
|
```
|
34
38
|
|
35
39
|
### Options
|
36
40
|
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
|
55
|
-
**Note**: All metadata options (
|
56
|
-
|
57
|
-
### Example
|
58
|
-
|
59
|
-
```
|
41
|
+
- `-t`, `--token`: (required) Oxygen deployment token. Can also be set using the `OXYGEN_DEPLOYMENT_TOKEN` environment variable (see below).
|
42
|
+
- `-p`, `--path`: Root path (defaults to the current working directory).
|
43
|
+
- `-e`, `--environmentTag`: Tag of the environment to deploy to. Defaults to branch name in supported CI environments (see below).
|
44
|
+
- `--defaultEnvironment`: Deploys to the default environment of the app.
|
45
|
+
- `-w`, `--workerFolder`: Worker folder (default: `dist/worker/`).
|
46
|
+
- `-a`, `--assetsFolder`: Assets folder (default: `dist/client/`).
|
47
|
+
- `-o`, `--workerOnly`: Worker only deployment.
|
48
|
+
- `-s`, `--skipBuild`: Skip running build command.
|
49
|
+
- `-b`, `--buildCommand`: Build command (default: `npm build`).
|
50
|
+
- `-v`, `--skipVerification`: skip the worker deployment verification step
|
51
|
+
- `-d`, `--verificationMaxDuration`: The maximum duration (in seconds) that the deployment verification is allowed to run before it is considered failed. Accepts values between 10 and 300.
|
52
|
+
- `--metadataDescription`: A brief description of the deployment, typically the commit message associated with the changes being deployed.
|
53
|
+
- `--metadataUrl`: URL linking to the workflow/pipeline run in the CI platform from which the deployment is performed.
|
54
|
+
- `--metadataUser`: User that initiated the deployment.
|
55
|
+
- `--metadataVersion`: A version identifier for the deployment.
|
56
|
+
- `--disableBugsnag`: Disable Bugsnag error reporting.
|
57
|
+
- `--generateAuthBypassToken`: Generate an auth bypass token used to perform end-to-end testing against the deployment.
|
58
|
+
|
59
|
+
**Note**: All metadata options (`--metadataDescription`, `--metadataUrl`, `--metadataUser`, and `--metadataVersion`) have a maximum character limit of 375.
|
60
|
+
|
61
|
+
### Example
|
62
|
+
|
63
|
+
```sh
|
60
64
|
oxygen:deploy -t my-deployment-token -e staging --path="/my-project" --workerOnly
|
61
65
|
```
|
62
66
|
|
63
|
-
This command will deploy your Oxygen project to the staging
|
67
|
+
This command will deploy your Oxygen project to the environment tagged `staging` with the provided deployment token and root path. No static assets will be uploaded.
|
64
68
|
|
65
69
|
The `environmentTag` option and the `metadata` options serve as overrides for values that can be retrieved from supported CI environments, see the section on environment variables below.
|
66
70
|
|
@@ -68,7 +72,7 @@ The `environmentTag` option and the `metadata` options serve as overrides for va
|
|
68
72
|
|
69
73
|
By default, `oxygen-cli` performs a verification step to ensure the worker deployment process has completed successfully. This step attempts to confirm the successful deployment of your worker. However, please note that this verification step does not dispatch requests to the worker, so it does not validate that the worker is correctly handling requests.
|
70
74
|
|
71
|
-
If you wish to skip this verification step, you can use the
|
75
|
+
If you wish to skip this verification step, you can use the `--skipVerification` command flag.
|
72
76
|
|
73
77
|
The verification step runs for a default duration of 180 seconds. If the verification process does not complete successfully within this time, the deployment is considered unsuccessful. However, you can customize this duration using the --verificationMaxDuration command flag. This flag allows you to specify a maximum duration between 10 and 300 seconds for the verification process. If the verification process does not complete within your specified duration, the deployment will be considered unsuccessful.
|
74
78
|
|
@@ -78,7 +82,7 @@ In the case of the deployment verification failing, we recommend checking your S
|
|
78
82
|
|
79
83
|
The Oxygen deployment token can be specified with the `token` option. Alternatively, you can use the environment variable `OXYGEN_DEPLOYMENT_TOKEN` for this. In CI environments this is recommended. For example, when using CircleCI you can define a custom environment variable in your project settings which holds the token. The `OXYGEN_DEPLOYMENT_TOKEN` can then be populated with this variable's value in your `config.yml` file:
|
80
84
|
|
81
|
-
```
|
85
|
+
```yml
|
82
86
|
environment:
|
83
87
|
OXYGEN_DEPLOYMENT_TOKEN: ${YOUR_ENV_VARIABLE}
|
84
88
|
```
|
package/dist/utils/utils.js
CHANGED
@@ -8,7 +8,7 @@ import { AbortError } from '@shopify/cli-kit/node/error';
|
|
8
8
|
|
9
9
|
const deployDefaults = {
|
10
10
|
assetsDirDefault: "dist/client/",
|
11
|
-
buildCommandDefault: "
|
11
|
+
buildCommandDefault: "npm build",
|
12
12
|
verificationDurationDefault: 180,
|
13
13
|
maxUploadAttempts: 3,
|
14
14
|
maxResumabeUploadAttempts: 9,
|
package/dist/utils/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/utils.ts"],"names":["Header","path"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,QAAO,eAAc;AAC5B,SAAQ,qBAAoB;AAE5B,SAAQ,YAAY,sBAAqB;AACzC,SAAQ,YAAY,kBAAiB;AACrC,SAAQ,gBAAe;AACvB,SAAQ,kBAAiB;AAQlB,MAAM,iBAAkD;AAAA,EAC7D,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,6BAA6B;AAAA,EAC7B,mBAAmB;AAAA,EACnB,2BAA2B;AAAA,EAC3B,kBAAkB;AACpB;AAEO,SAAS,aAAa,OAAY;AACvC,MAAI,cAAc,KAAK,GAAG;AACxB,QAAI,MAAM,eAAe,KAAK;AAC5B,YAAM,IAAI;AAAA,QAC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EAC3E;AACF;AAEA,eAAe,UAAUC,OAAc,UAAkB;AACvD,MAAI,CAAE,MAAM,WAAWA,KAAI,GAAI;AAC7B,QAAI,aAAa,UAAU;AACzB;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,UAAM,IAAI,MAAM,mBAAmBA,KAAI,EAAE;AAAA,EAC3C;AACF;AAMA,SAAS,uBACP,KAC0B;AAC1B,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO,OAAO,KAAK,GAAG,EAAE,OAAO,CAAC,QAAa,QAAgB;AAC3D,YAAM,eAAe,IAAI;AAAA,QAAQ;AAAA,QAAiB,CAAC,OACjD,GAAG,YAAY,EAAE,QAAQ,KAAK,EAAE,EAAE,QAAQ,KAAK,EAAE;AAAA,MACnD;AACA,UAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,cAAM,IAAI,MAAM,kBAAkB,GAAG,eAAe;AAAA,MACtD;AACA,aAAO,YAAY,IAAI,uBAAuB,IAAI,GAAG,CAAc;AACnE,aAAO;AAAA,IACT,GAAG,CAAC,CAAoB;AAAA,EAC1B;AACA,SAAO;AACT","sourcesContent":["import fs from 'fs';\nimport path, {dirname} from 'path';\nimport {fileURLToPath} from 'url';\n\nimport {fileExists, fileExistsSync} from '@shopify/cli-kit/node/fs';\nimport {outputInfo, outputWarn} from '@shopify/cli-kit/node/output';\nimport {joinPath} from '@shopify/cli-kit/node/path';\nimport {AbortError} from '@shopify/cli-kit/node/error';\n\nimport {\n ClientError,\n DeploymentConfig,\n DeploymentToken,\n} from '../deploy/types.js';\n\nexport const deployDefaults: Record<string, string | number> = {\n assetsDirDefault: 'dist/client/',\n buildCommandDefault: '
|
1
|
+
{"version":3,"sources":["../../src/utils/utils.ts"],"names":["Header","path"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,QAAO,eAAc;AAC5B,SAAQ,qBAAoB;AAE5B,SAAQ,YAAY,sBAAqB;AACzC,SAAQ,YAAY,kBAAiB;AACrC,SAAQ,g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CAAC,YAAY;AACf,iBAAW,SAAS,SAAS,UAAW,SAAU;AAAA,IACpD;AAAA,EACF;AAEA,aAAW,YAAY,OAAO,KAAK,UAAU,GAAG;AAC9C,UAAM,UAAU,WAAW,QAAQ,GAAI,QAAQ;AAAA,EACjD;AAEA,QAAM,eACJ;AACF,MAAI,CAAC,aAAa,KAAK,OAAO,aAAa,GAAG;AAC5C,UAAM,IAAI,MAAM,mCAAmC,OAAO,aAAa,EAAE;AAAA,EAC3E;AACF;AAEA,eAAe,UAAUC,OAAc,UAAkB;AACvD,MAAI,CAAE,MAAM,WAAWA,KAAI,GAAI;AAC7B,QAAI,aAAa,UAAU;AACzB;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,UAAM,IAAI,MAAM,mBAAmBA,KAAI,EAAE;AAAA,EAC3C;AACF;AAMA,SAAS,uBACP,KAC0B;AAC1B,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO,OAAO,KAAK,GAAG,EAAE,OAAO,CAAC,QAAa,QAAgB;AAC3D,YAAM,eAAe,IAAI;AAAA,QAAQ;AAAA,QAAiB,CAAC,OACjD,GAAG,YAAY,EAAE,QAAQ,KAAK,EAAE,EAAE,QAAQ,KAAK,EAAE;AAAA,MACnD;AACA,UAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,cAAM,IAAI,MAAM,kBAAkB,GAAG,eAAe;AAAA,MACtD;AACA,aAAO,YAAY,IAAI,uBAAuB,IAAI,GAAG,CAAc;AACnE,aAAO;AAAA,IACT,GAAG,CAAC,CAAoB;AAAA,EAC1B;AACA,SAAO;AACT","sourcesContent":["import fs from 'fs';\nimport path, {dirname} from 'path';\nimport {fileURLToPath} from 'url';\n\nimport {fileExists, fileExistsSync} from '@shopify/cli-kit/node/fs';\nimport {outputInfo, outputWarn} from '@shopify/cli-kit/node/output';\nimport {joinPath} from '@shopify/cli-kit/node/path';\nimport {AbortError} from '@shopify/cli-kit/node/error';\n\nimport {\n ClientError,\n DeploymentConfig,\n DeploymentToken,\n} from '../deploy/types.js';\n\nexport const deployDefaults: Record<string, string | number> = {\n assetsDirDefault: 'dist/client/',\n buildCommandDefault: 'npm build',\n verificationDurationDefault: 180,\n maxUploadAttempts: 3,\n maxResumabeUploadAttempts: 9,\n workerDirDefault: 'dist/worker/',\n};\n\nexport function errorHandler(error: any) {\n if (isClientError(error)) {\n if (error.statusCode === 401) {\n throw new AbortError(\n 'You are not authorized to perform this action. Please check your deployment token.',\n );\n }\n\n if (error.statusCode === 429) {\n throw new AbortError(\n \"You've made too many requests. Please try again later\",\n );\n }\n }\n\n if (error instanceof AbortError && error.message.includes('503')) {\n throw new AbortError(\n 'The server is currently unavailable. Please try again later.',\n );\n }\n}\n\nexport function getBuildCommandFromLockFile(config: DeploymentConfig): string {\n const lockFileBuildCommands = new Map([\n ['package-lock.json', 'npm run build'],\n ['pnpm-lock.yaml', 'pnpm run build'],\n ['yarn.lock', 'yarn build'],\n ]);\n\n const foundLockFiles = [];\n\n for (const [lockFileName, buildCommand] of lockFileBuildCommands) {\n if (fileExistsSync(joinPath(config.rootPath!, lockFileName))) {\n foundLockFiles.push({lockFileName, buildCommand});\n }\n }\n\n if (foundLockFiles.length > 1) {\n const lockFilesList = foundLockFiles\n .map(({lockFileName}) => lockFileName)\n .join(', ');\n outputWarn(\n `Warning: Multiple lock files found: (${lockFilesList}).`,\n stderrLogger,\n );\n }\n\n if (foundLockFiles.length > 0) {\n const {lockFileName, buildCommand} = foundLockFiles[0] as {\n lockFileName: string;\n buildCommand: string;\n };\n\n const infoMsg = foundLockFiles.length > 1 ? '' : `Found: ${lockFileName}. `;\n\n outputInfo(\n `${infoMsg}Assuming \"${buildCommand}\" as build command. Use the buildCommand flag to override.`,\n stderrLogger,\n );\n return buildCommand;\n }\n\n return String(deployDefaults.buildCommandDefault);\n}\n\nexport enum Header {\n OxygenNamespaceHandle = 'X-Oxygen-Namespace-Handle',\n}\n\nexport function isClientError(error: unknown): error is ClientError {\n return typeof error === 'object' && error !== null && 'statusCode' in error;\n}\n\nexport function loadPackageJson(projectFolder?: string) {\n let jsonPath;\n if (projectFolder) {\n jsonPath = path.join(projectFolder, 'package.json');\n } else {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n jsonPath = path.join(__dirname, '../../package.json');\n }\n\n if (!fs.existsSync(jsonPath)) {\n return {};\n }\n const packageJsonData = fs.readFileSync(jsonPath, 'utf8');\n return JSON.parse(packageJsonData);\n}\n\nexport function stderrLogger(log: string): void {\n process.stderr.write(`${log}\\n`);\n}\n\nexport const maxLabelLength = 375;\n\nexport function parseToken(inputToken: string): DeploymentToken {\n try {\n const decodedToken = Buffer.from(inputToken, 'base64').toString('utf-8');\n const rawToken = JSON.parse(decodedToken);\n return convertKeysToCamelCase(rawToken) as DeploymentToken;\n } catch (error) {\n throw new Error(\n `Error processing deployment token. Please check your token and try again.`,\n );\n }\n}\n\ninterface VerifyConfigParams {\n config: DeploymentConfig;\n performedBuild?: boolean;\n}\n\nexport async function verifyConfig({\n config,\n performedBuild = false,\n}: VerifyConfigParams) {\n const {rootPath, workerDir, assetsDir, skipBuild, workerOnly} = config;\n const checkPaths: Record<string, string> = {\n root: rootPath!,\n };\n\n if (skipBuild || performedBuild) {\n checkPaths.worker = joinPath(rootPath!, workerDir!);\n if (!workerOnly) {\n checkPaths.assets = joinPath(rootPath!, assetsDir!);\n }\n }\n\n for (const pathType of Object.keys(checkPaths)) {\n await checkPath(checkPaths[pathType]!, pathType);\n }\n\n const addressRegex =\n /^https:\\/\\/(?:[\\w-]+\\.)*[\\w-]+|^https:\\/\\/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/;\n if (!addressRegex.test(config.deploymentUrl)) {\n throw new Error(`Invalid deployment service URL: ${config.deploymentUrl}`);\n }\n}\n\nasync function checkPath(path: string, pathType: string) {\n if (!(await fileExists(path))) {\n if (pathType === 'assets') {\n outputWarn(\n `Use the \"workerOnly\" flag to perform a worker-only deployment.`,\n stderrLogger,\n );\n }\n throw new Error(`Path not found: ${path}`);\n }\n}\n\ninterface TokenType {\n [x: string]: string | TokenType;\n}\n\nfunction convertKeysToCamelCase(\n obj: TokenType | string,\n): DeploymentToken | string {\n if (typeof obj === 'object') {\n return Object.keys(obj).reduce((result: any, key: string) => {\n const camelCaseKey = key.replace(/([-_][a-z])/gi, ($1) =>\n $1.toUpperCase().replace('-', '').replace('_', ''),\n );\n if (obj[key] === undefined) {\n throw new Error(`Invalid token: ${key} is undefined`);\n }\n result[camelCaseKey] = convertKeysToCamelCase(obj[key] as TokenType);\n return result;\n }, {} as DeploymentToken);\n }\n return obj;\n}\n"]}
|
package/oclif.manifest.json
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
"description": "Build command",
|
21
21
|
"name": "buildCommand",
|
22
22
|
"required": false,
|
23
|
-
"default": "
|
23
|
+
"default": "npm build",
|
24
24
|
"hasDynamicHelp": false,
|
25
25
|
"multiple": false,
|
26
26
|
"type": "option"
|
@@ -174,5 +174,5 @@
|
|
174
174
|
]
|
175
175
|
}
|
176
176
|
},
|
177
|
-
"version": "4.0.1-unstable.
|
177
|
+
"version": "4.0.1-unstable.202401192311.0"
|
178
178
|
}
|
package/package.json
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
6
6
|
},
|
7
7
|
"license": "MIT",
|
8
|
-
"version": "4.0.1-unstable.
|
8
|
+
"version": "4.0.1-unstable.202401192311.0",
|
9
9
|
"type": "module",
|
10
10
|
"scripts": {
|
11
11
|
"build": "tsup --sourcemap --clean --config ./tsup.config.ts && oclif manifest",
|