@shopify/oxygen-cli 1.8.2 → 1.9.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.
@@ -21,7 +21,8 @@ async function getUploadFiles(config) {
21
21
  ...createManifestEntries({
22
22
  files: assetFiles,
23
23
  basePath: assetPath,
24
- type: FileType.Asset
24
+ type: FileType.Asset,
25
+ filter: assetFileFilter
25
26
  })
26
27
  ];
27
28
  }
@@ -36,7 +37,7 @@ function createManifestEntries(params) {
36
37
  const manifest = [];
37
38
  files.forEach((file) => {
38
39
  const filePath = relativePath(basePath, file);
39
- if (filter && !filter(filePath, type)) {
40
+ if (filter && !filter(filePath)) {
40
41
  return;
41
42
  }
42
43
  manifest.push({
@@ -49,17 +50,20 @@ function createManifestEntries(params) {
49
50
  });
50
51
  return manifest;
51
52
  }
52
- function workerFileFilter(fileName, type) {
53
- if (type === FileType.Asset) {
54
- return true;
55
- }
53
+ function workerFileFilter(fileName) {
56
54
  const allowedExtensions = [".js.map", ".mjs.map", ".map", ".js", ".mjs"];
57
55
  const allowedFilenames = ["index"];
58
56
  const regexString = `^(${allowedFilenames.join(
59
57
  "|"
60
58
  )})(${allowedExtensions.join("|")})$`;
61
59
  const regex = new RegExp(regexString);
62
- return regex.test(fileName);
60
+ return regex.test(fileName.toLowerCase());
61
+ }
62
+ function assetFileFilter(fileName) {
63
+ const disallowedExtensions = [".map"];
64
+ const regexString = `(${disallowedExtensions.join("|")})$`;
65
+ const regex = new RegExp(regexString);
66
+ return !regex.test(fileName.toLowerCase());
63
67
  }
64
68
 
65
69
  export { getUploadFiles };
@@ -38,7 +38,7 @@ describe("GetUploadFiles", () => {
38
38
  ];
39
39
  expect(manifest).toEqual(expectedManifest);
40
40
  });
41
- test("GetUploadFiles manifest does not included non-worker files", async () => {
41
+ test("GetUploadFiles manifest does not include non-worker files", async () => {
42
42
  await touchFile(`${rootFolder}/worker/image.jpg`);
43
43
  await touchFile(`${rootFolder}/worker/worker.ts`);
44
44
  await touchFile(`${rootFolder}/worker/index.js.map`);
@@ -53,4 +53,15 @@ describe("GetUploadFiles", () => {
53
53
  expect(workerFileExist("index.js.map")).toBe(true);
54
54
  expect(workerFileExist("index.js")).toBe(true);
55
55
  });
56
+ test("GetUploadFiles manifest does not include source map files in assets", async () => {
57
+ const testFilename = "index.js.MaP";
58
+ await touchFile(`${rootFolder}/assets/${testFilename}`);
59
+ const manifest = await getUploadFiles(testConfig);
60
+ const assetSourcemapFileExist = (fileName) => {
61
+ return manifest.some(
62
+ (file) => file.filePath === fileName && file.fileType === FileType.Asset
63
+ );
64
+ };
65
+ expect(assetSourcemapFileExist(testFilename)).toBe(false);
66
+ });
56
67
  });
@@ -45,20 +45,31 @@ function createLabels(metadata) {
45
45
  const label = `${labelKey}=${JSON.stringify(labelValue)}`;
46
46
  labels.push(label);
47
47
  };
48
- if (metadata.name !== "unknown" && metadata.run) {
49
- labels.push(`${metadata.name}-runId=${JSON.stringify(metadata.run)}`);
48
+ if (metadata.name !== "unknown") {
49
+ const keyMapping2 = {
50
+ attempt: "attempt",
51
+ run: "runId"
52
+ };
53
+ for (const [key, value] of Object.entries(keyMapping2)) {
54
+ const metadataKey = key;
55
+ if (metadata[metadataKey]) {
56
+ labels.push(
57
+ `${metadata.name}-${value}=${JSON.stringify(metadata[metadataKey])}`
58
+ );
59
+ }
60
+ }
50
61
  }
51
- const keys = ["url", "actor", "commitSha"];
52
62
  const keyMapping = {
53
63
  actor: "user",
54
- commitSha: "version"
64
+ commitSha: "version",
65
+ url: "url"
55
66
  };
56
- keys.forEach((key) => {
57
- if (metadata[key]) {
58
- const labelKey = keyMapping[key] || key;
59
- checkLabel(labelKey, metadata[key]);
67
+ for (const [key, value] of Object.entries(keyMapping)) {
68
+ const metadataKey = key;
69
+ if (metadata[metadataKey]) {
70
+ checkLabel(value, metadata[metadataKey]);
60
71
  }
61
- });
72
+ }
62
73
  return labels;
63
74
  }
64
75
 
@@ -105,18 +105,19 @@ describe("createLabels", () => {
105
105
  };
106
106
  const labels = [
107
107
  'circle-runId="circle_1234"',
108
- 'url="http://circleci.com/workflow/123"',
109
108
  'user="circle_actor"',
110
- 'version="circle_sha"'
109
+ 'version="circle_sha"',
110
+ 'url="http://circleci.com/workflow/123"'
111
111
  ];
112
112
  expect(createLabels(metadata)).toEqual(labels);
113
113
  });
114
114
  test("should return labels from metadata only for populated fields", () => {
115
115
  const metadata = {
116
116
  name: "circle",
117
- run: "circle_run"
117
+ run: "circle_run",
118
+ attempt: "1"
118
119
  };
119
- const labels = ['circle-runId="circle_run"'];
120
+ const labels = ['circle-attempt="1"', 'circle-runId="circle_run"'];
120
121
  expect(createLabels(metadata)).toEqual(labels);
121
122
  });
122
123
  test("should throw when user metadata exceeds maximum length", () => {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.2",
2
+ "version": "1.9.0",
3
3
  "commands": {
4
4
  "oxygen:deploy": {
5
5
  "id": "oxygen:deploy",
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "@shopify:registry": "https://registry.npmjs.org"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "1.8.2",
8
+ "version": "1.9.0",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "build": "tsup --clean --config ./tsup.config.ts && oclif manifest",
@@ -34,24 +34,24 @@
34
34
  "/oclif.manifest.json"
35
35
  ],
36
36
  "dependencies": {
37
- "@oclif/core": "2.11.5",
38
- "@shopify/cli-kit": "^3.48.0",
37
+ "@oclif/core": "2.11.8",
38
+ "@shopify/cli-kit": "nightly",
39
39
  "async": "^3.2.4"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@changesets/cli": "^2.26.1",
43
- "@shopify/eslint-plugin": "^42.1.0",
43
+ "@shopify/eslint-plugin": "^43.0.0",
44
44
  "@shopify/prettier-config": "^1.1.2",
45
45
  "@types/async": "^3.2.18",
46
- "@types/node": "^20.4.5",
47
- "@types/prettier": "^3.0.0",
48
- "eslint": "^8.46.0",
46
+ "@types/node": "^20.5.0",
47
+ "eslint": "^8.47.0",
48
+ "eslint-plugin-prettier": "^5.0.0",
49
49
  "node-fetch": "^3.3.2",
50
50
  "oclif": "^3",
51
- "tsup": "^7.1.0",
51
+ "tsup": "^7.2.0",
52
52
  "typescript": "^5.1.3",
53
- "vite": "^4.4.8",
54
- "vitest": "^0.33.0"
53
+ "vite": "^4.4.9",
54
+ "vitest": "^0.34.1"
55
55
  },
56
56
  "prettier": "@shopify/prettier-config",
57
57
  "oclif": {