skuba 10.0.4 → 10.1.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.
@@ -0,0 +1,2 @@
1
+ import type { Patches } from '../..';
2
+ export declare const patches: Patches;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __exports = {};
20
+ __export(__exports, {
21
+ patches: () => patches
22
+ });
23
+ module.exports = __toCommonJS(__exports);
24
+ var import_removeYarnIgnoreOptionalFlags = require("./removeYarnIgnoreOptionalFlags");
25
+ const patches = [
26
+ {
27
+ apply: import_removeYarnIgnoreOptionalFlags.tryRemoveYarnIgnoreOptionalFlags,
28
+ description: "Remove yarn --ignore-optional flags in Dockerfiles"
29
+ }
30
+ ];
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ patches
34
+ });
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.0.4/index.ts"],
4
+ "sourcesContent": ["import type { Patches } from '../..';\n\nimport { tryRemoveYarnIgnoreOptionalFlags } from './removeYarnIgnoreOptionalFlags';\n\nexport const patches: Patches = [\n {\n apply: tryRemoveYarnIgnoreOptionalFlags,\n description: 'Remove yarn --ignore-optional flags in Dockerfiles',\n },\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2CAAiD;AAE1C,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { PatchFunction } from '../..';
2
+ export declare const tryRemoveYarnIgnoreOptionalFlags: PatchFunction;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var removeYarnIgnoreOptionalFlags_exports = {};
20
+ __export(removeYarnIgnoreOptionalFlags_exports, {
21
+ tryRemoveYarnIgnoreOptionalFlags: () => tryRemoveYarnIgnoreOptionalFlags
22
+ });
23
+ module.exports = __toCommonJS(removeYarnIgnoreOptionalFlags_exports);
24
+ var import_util = require("util");
25
+ var import_fast_glob = require("fast-glob");
26
+ var import_fs_extra = require("fs-extra");
27
+ var import_logging = require("../../../../../../utils/logging");
28
+ const fetchFiles = async (files) => Promise.all(
29
+ files.map(async (file) => {
30
+ const contents = await import_fs_extra.promises.readFile(file, "utf8");
31
+ return {
32
+ file,
33
+ contents
34
+ };
35
+ })
36
+ );
37
+ const regex = /\s*--ignore-optional/;
38
+ const removeYarnIgnoreFlag = (contents) => {
39
+ let isInYarn = false;
40
+ const lines = contents.split("\n");
41
+ for (let i = 0; i < lines.length; i++) {
42
+ const line = lines[i];
43
+ if (line.includes("yarn")) isInYarn = true;
44
+ if (isInYarn && regex.test(line)) {
45
+ lines[i] = line.replace(regex, "");
46
+ if (!lines[i].trim()) {
47
+ lines.splice(i, 1);
48
+ if (i > 0) {
49
+ lines[i - 1] = lines[i - 1].replace(/\s*\\$/, "");
50
+ }
51
+ i--;
52
+ } else if (lines[i] === "\\") {
53
+ lines.splice(i, 1);
54
+ i--;
55
+ }
56
+ isInYarn = false;
57
+ }
58
+ if (!line.endsWith("\\")) isInYarn = false;
59
+ }
60
+ return lines.join("\n");
61
+ };
62
+ const removeYarnIgnoreOptionalFlags = async ({
63
+ mode
64
+ }) => {
65
+ const maybeDockerFilesPaths = await (0, import_fast_glob.glob)(["Dockerfile*"]);
66
+ if (!maybeDockerFilesPaths.length) {
67
+ return {
68
+ result: "skip",
69
+ reason: "no Dockerfiles found"
70
+ };
71
+ }
72
+ const dockerFiles = await fetchFiles(maybeDockerFilesPaths);
73
+ const mapped = dockerFiles.map(({ file, contents }) => ({
74
+ file,
75
+ before: contents,
76
+ after: removeYarnIgnoreFlag(contents)
77
+ }));
78
+ if (!mapped.some(({ before, after }) => before !== after)) {
79
+ return {
80
+ result: "skip",
81
+ reason: "no Dockerfiles to patch"
82
+ };
83
+ }
84
+ if (mode === "lint") {
85
+ return {
86
+ result: "apply"
87
+ };
88
+ }
89
+ await Promise.all(
90
+ mapped.map(async ({ file, after }) => {
91
+ await import_fs_extra.promises.writeFile(file, after);
92
+ })
93
+ );
94
+ return { result: "apply" };
95
+ };
96
+ const tryRemoveYarnIgnoreOptionalFlags = async (config) => {
97
+ try {
98
+ return await removeYarnIgnoreOptionalFlags(config);
99
+ } catch (err) {
100
+ import_logging.log.warn("Failed to remove yarn --ignore-optional flags");
101
+ import_logging.log.subtle((0, import_util.inspect)(err));
102
+ return { result: "skip", reason: "due to an error" };
103
+ }
104
+ };
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ tryRemoveYarnIgnoreOptionalFlags
108
+ });
109
+ //# sourceMappingURL=removeYarnIgnoreOptionalFlags.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport { promises as fs } from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\nconst regex = /\\s*--ignore-optional/;\n\nconst removeYarnIgnoreFlag = (contents: string) => {\n let isInYarn = false;\n\n const lines = contents.split('\\n');\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n\n if (line.includes('yarn')) isInYarn = true;\n\n if (isInYarn && regex.test(line)) {\n lines[i] = line.replace(regex, '');\n\n // If we're now an empty line, remove it and get rid of the \\ at the end of the previous line\n if (!lines[i]!.trim()) {\n lines.splice(i, 1);\n if (i > 0) {\n lines[i - 1] = lines[i - 1]!.replace(/\\s*\\\\$/, '');\n }\n i--;\n } else if (lines[i] === '\\\\') {\n lines.splice(i, 1);\n i--;\n }\n\n isInYarn = false;\n }\n\n if (!line.endsWith('\\\\')) isInYarn = false;\n }\n\n return lines.join('\\n');\n};\n\nconst removeYarnIgnoreOptionalFlags: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const maybeDockerFilesPaths = await glob(['Dockerfile*']);\n\n if (!maybeDockerFilesPaths.length) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles found',\n };\n }\n\n const dockerFiles = await fetchFiles(maybeDockerFilesPaths);\n\n const mapped = dockerFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: removeYarnIgnoreFlag(contents),\n }));\n\n if (!mapped.some(({ before, after }) => before !== after)) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles to patch',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n mapped.map(async ({ file, after }) => {\n await fs.writeFile(file, after);\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const tryRemoveYarnIgnoreOptionalFlags: PatchFunction = async (\n config,\n) => {\n try {\n return await removeYarnIgnoreOptionalFlags(config);\n } catch (err) {\n log.warn('Failed to remove yarn --ignore-optional flags');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAwB;AAExB,uBAAqB;AACrB,sBAA+B;AAG/B,qBAAoB;AAEpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,gBAAAA,SAAG,SAAS,MAAM,MAAM;AAE/C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEF,MAAM,QAAQ;AAEd,MAAM,uBAAuB,CAAC,aAAqB;AACjD,MAAI,WAAW;AAEf,QAAM,QAAQ,SAAS,MAAM,IAAI;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,OAAO,MAAM,CAAC;AAEpB,QAAI,KAAK,SAAS,MAAM,EAAG,YAAW;AAEtC,QAAI,YAAY,MAAM,KAAK,IAAI,GAAG;AAChC,YAAM,CAAC,IAAI,KAAK,QAA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mCAAkD,OAC7D,WACG;AACH,MAAI;AACF,WAAO,MAAM,8BAA8B,MAAM;AAAA,EACnD,SAAS,KAAK;AACZ,uBAAI,KAAK,+CAA+C;AACxD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skuba",
3
- "version": "10.0.4",
3
+ "version": "10.1.0",
4
4
  "private": false,
5
5
  "description": "SEEK development toolkit for backend applications and packages",
6
6
  "homepage": "https://github.com/seek-oss/skuba#readme",
@@ -98,7 +98,7 @@
98
98
  "tsx": "^4.16.2",
99
99
  "typescript": "~5.8.0",
100
100
  "zod": "^3.22.4",
101
- "eslint-config-skuba": "5.1.2"
101
+ "eslint-config-skuba": "5.1.3"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@changesets/cli": "2.28.1",
@@ -149,7 +149,7 @@
149
149
  "entryPoint": "src/index.ts",
150
150
  "template": null,
151
151
  "type": "package",
152
- "version": "10.0.0"
152
+ "version": "10.1.0"
153
153
  },
154
154
  "scripts": {
155
155
  "build": "scripts/build.sh",