@aidc-toolkit/dev 0.9.4 → 0.9.6-beta

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,25 @@
1
+ {
2
+ "organization": "aidc-toolkit",
3
+ "repositories": {
4
+ "dev": {
5
+ "version": "0.9.6-beta"
6
+ },
7
+ "core": {
8
+ "version": "0.9.6-beta"
9
+ },
10
+ "utility": {
11
+ "version": "0.9.6-beta"
12
+ },
13
+ "gs1": {
14
+ "name": "gs1",
15
+ "version": "0.9.6-beta"
16
+ },
17
+ "demo": {
18
+ "version": "0.9.6-beta"
19
+ },
20
+ "aidc-toolkit.github.io": {
21
+ "directory": "doc",
22
+ "version": "0.9.6-beta"
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "copyFiles": [
3
+ {
4
+ "from": ".github/workflows/tag.yml",
5
+ "to": "../core/.github/workflows/"
6
+ },
7
+ {
8
+ "from": ".github/workflows/tag.yml",
9
+ "to": "../utility/.github/workflows/"
10
+ },
11
+ {
12
+ "from": ".github/workflows/tag.yml",
13
+ "to": "../gs1/.github/workflows/"
14
+ },
15
+ {
16
+ "from": ".github/workflows/tag.yml",
17
+ "to": "../demo/.github/workflows/"
18
+ },
19
+ {
20
+ "from": ".github/workflows/tag.yml",
21
+ "to": "../doc/.github/workflows/"
22
+ },
23
+ {
24
+ "from": ".github/workflows/release.yml",
25
+ "to": "../core/.github/workflows/"
26
+ },
27
+ {
28
+ "from": ".github/workflows/release.yml",
29
+ "to": "../utility/.github/workflows/"
30
+ },
31
+ {
32
+ "from": ".github/workflows/release.yml",
33
+ "to": "../gs1/.github/workflows/"
34
+ }
35
+ ],
36
+
37
+ "copyFilesSettings": {
38
+ "whenFileExists": "overwrite"
39
+ }
40
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ esLintConfigAIDCToolkit: () => esLintConfigAIDCToolkit
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/eslint.config.template.ts
38
+ var import_js = __toESM(require("@eslint/js"), 1);
39
+ var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
40
+ var import_eslint_config_love = __toESM(require("eslint-config-love"), 1);
41
+ var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
42
+ var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
43
+ var esLintConfigAIDCToolkit = import_typescript_eslint.default.config(
44
+ {
45
+ ignores: ["eslint.config.js", "dist"]
46
+ },
47
+ import_js.default.configs.recommended,
48
+ ...import_typescript_eslint.default.configs.strictTypeChecked,
49
+ import_eslint_plugin.default.configs["recommended-flat"],
50
+ import_eslint_plugin_jsdoc.default.configs["flat/recommended-typescript"],
51
+ import_eslint_config_love.default,
52
+ {
53
+ languageOptions: {
54
+ parserOptions: {
55
+ projectService: true
56
+ }
57
+ },
58
+ linterOptions: {
59
+ reportUnusedDisableDirectives: "error"
60
+ },
61
+ rules: {
62
+ "complexity": "off",
63
+ "no-dupe-class-members": "off",
64
+ "no-redeclare": "off",
65
+ "no-unused-vars": "off",
66
+ "@typescript-eslint/class-literal-property-style": "off",
67
+ "@typescript-eslint/class-methods-use-this": "off",
68
+ "@typescript-eslint/init-declarations": "off",
69
+ "@typescript-eslint/max-params": "off",
70
+ "@typescript-eslint/no-empty-function": "off",
71
+ "@typescript-eslint/no-empty-object-type": "off",
72
+ "@typescript-eslint/no-magic-numbers": "off",
73
+ "@typescript-eslint/no-unnecessary-type-parameters": "off",
74
+ "@typescript-eslint/no-unused-vars": [
75
+ "error",
76
+ {
77
+ argsIgnorePattern: "^_",
78
+ varsIgnorePattern: "^_",
79
+ caughtErrorsIgnorePattern: "^_"
80
+ }
81
+ ],
82
+ "@typescript-eslint/prefer-destructuring": "off",
83
+ "@typescript-eslint/unbound-method": ["error", {
84
+ ignoreStatic: true
85
+ }],
86
+ "@stylistic/array-bracket-newline": ["error", "consistent"],
87
+ "@stylistic/brace-style": ["error", "1tbs", {
88
+ allowSingleLine: false
89
+ }],
90
+ "@stylistic/comma-dangle": ["error", "never"],
91
+ "@stylistic/indent": ["error", 4],
92
+ "@stylistic/member-delimiter-style": ["error", {
93
+ multiline: {
94
+ delimiter: "semi",
95
+ requireLast: true
96
+ },
97
+ singleline: {
98
+ delimiter: "semi"
99
+ }
100
+ }],
101
+ "@stylistic/no-trailing-spaces": ["off"],
102
+ "@stylistic/operator-linebreak": ["error", "after"],
103
+ "@stylistic/quotes": ["error", "double"],
104
+ "@stylistic/semi": ["error", "always"],
105
+ "@stylistic/object-curly-newline": ["error", {
106
+ ObjectExpression: {
107
+ multiline: true,
108
+ minProperties: 1
109
+ },
110
+ ObjectPattern: {
111
+ multiline: true,
112
+ minProperties: 1
113
+ }
114
+ }],
115
+ "@stylistic/object-property-newline": "error",
116
+ "jsdoc/require-description": ["warn", {
117
+ contexts: ["ClassDeclaration", "ClassProperty", "FunctionDeclaration", "MethodDefinition", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSModuleDeclaration", "TSTypeAliasDeclaration"]
118
+ }],
119
+ "jsdoc/require-jsdoc": ["warn", {
120
+ contexts: ["ClassDeclaration", "ClassProperty", "FunctionDeclaration", "MethodDefinition", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSModuleDeclaration", "TSTypeAliasDeclaration"]
121
+ }],
122
+ "jsdoc/require-returns": ["warn", {
123
+ checkGetters: false
124
+ }],
125
+ "jsdoc/tag-lines": ["warn", "any", {
126
+ count: 1,
127
+ startLines: 1
128
+ }]
129
+ }
130
+ },
131
+ {
132
+ files: [
133
+ "test/**/*"
134
+ ],
135
+ rules: {
136
+ "jsdoc/require-jsdoc": "off",
137
+ "@typescript-eslint/dot-notation": "off",
138
+ "@typescript-eslint/no-unsafe-type-assertion": "off"
139
+ }
140
+ }
141
+ );
142
+ // Annotate the CommonJS export names for ESM import in node:
143
+ 0 && (module.exports = {
144
+ esLintConfigAIDCToolkit
145
+ });
@@ -0,0 +1,5 @@
1
+ import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
+
3
+ declare const esLintConfigAIDCToolkit: _typescript_eslint_utils_ts_eslint.FlatConfig.ConfigArray;
4
+
5
+ export { esLintConfigAIDCToolkit };
@@ -0,0 +1,5 @@
1
+ import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
+
3
+ declare const esLintConfigAIDCToolkit: _typescript_eslint_utils_ts_eslint.FlatConfig.ConfigArray;
4
+
5
+ export { esLintConfigAIDCToolkit };
package/dist/index.js ADDED
@@ -0,0 +1,108 @@
1
+ // src/eslint.config.template.ts
2
+ import js from "@eslint/js";
3
+ import stylistic from "@stylistic/eslint-plugin";
4
+ import esLintConfigLove from "eslint-config-love";
5
+ import jsdoc from "eslint-plugin-jsdoc";
6
+ import tseslint from "typescript-eslint";
7
+ var esLintConfigAIDCToolkit = tseslint.config(
8
+ {
9
+ ignores: ["eslint.config.js", "dist"]
10
+ },
11
+ js.configs.recommended,
12
+ ...tseslint.configs.strictTypeChecked,
13
+ stylistic.configs["recommended-flat"],
14
+ jsdoc.configs["flat/recommended-typescript"],
15
+ esLintConfigLove,
16
+ {
17
+ languageOptions: {
18
+ parserOptions: {
19
+ projectService: true
20
+ }
21
+ },
22
+ linterOptions: {
23
+ reportUnusedDisableDirectives: "error"
24
+ },
25
+ rules: {
26
+ "complexity": "off",
27
+ "no-dupe-class-members": "off",
28
+ "no-redeclare": "off",
29
+ "no-unused-vars": "off",
30
+ "@typescript-eslint/class-literal-property-style": "off",
31
+ "@typescript-eslint/class-methods-use-this": "off",
32
+ "@typescript-eslint/init-declarations": "off",
33
+ "@typescript-eslint/max-params": "off",
34
+ "@typescript-eslint/no-empty-function": "off",
35
+ "@typescript-eslint/no-empty-object-type": "off",
36
+ "@typescript-eslint/no-magic-numbers": "off",
37
+ "@typescript-eslint/no-unnecessary-type-parameters": "off",
38
+ "@typescript-eslint/no-unused-vars": [
39
+ "error",
40
+ {
41
+ argsIgnorePattern: "^_",
42
+ varsIgnorePattern: "^_",
43
+ caughtErrorsIgnorePattern: "^_"
44
+ }
45
+ ],
46
+ "@typescript-eslint/prefer-destructuring": "off",
47
+ "@typescript-eslint/unbound-method": ["error", {
48
+ ignoreStatic: true
49
+ }],
50
+ "@stylistic/array-bracket-newline": ["error", "consistent"],
51
+ "@stylistic/brace-style": ["error", "1tbs", {
52
+ allowSingleLine: false
53
+ }],
54
+ "@stylistic/comma-dangle": ["error", "never"],
55
+ "@stylistic/indent": ["error", 4],
56
+ "@stylistic/member-delimiter-style": ["error", {
57
+ multiline: {
58
+ delimiter: "semi",
59
+ requireLast: true
60
+ },
61
+ singleline: {
62
+ delimiter: "semi"
63
+ }
64
+ }],
65
+ "@stylistic/no-trailing-spaces": ["off"],
66
+ "@stylistic/operator-linebreak": ["error", "after"],
67
+ "@stylistic/quotes": ["error", "double"],
68
+ "@stylistic/semi": ["error", "always"],
69
+ "@stylistic/object-curly-newline": ["error", {
70
+ ObjectExpression: {
71
+ multiline: true,
72
+ minProperties: 1
73
+ },
74
+ ObjectPattern: {
75
+ multiline: true,
76
+ minProperties: 1
77
+ }
78
+ }],
79
+ "@stylistic/object-property-newline": "error",
80
+ "jsdoc/require-description": ["warn", {
81
+ contexts: ["ClassDeclaration", "ClassProperty", "FunctionDeclaration", "MethodDefinition", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSModuleDeclaration", "TSTypeAliasDeclaration"]
82
+ }],
83
+ "jsdoc/require-jsdoc": ["warn", {
84
+ contexts: ["ClassDeclaration", "ClassProperty", "FunctionDeclaration", "MethodDefinition", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSModuleDeclaration", "TSTypeAliasDeclaration"]
85
+ }],
86
+ "jsdoc/require-returns": ["warn", {
87
+ checkGetters: false
88
+ }],
89
+ "jsdoc/tag-lines": ["warn", "any", {
90
+ count: 1,
91
+ startLines: 1
92
+ }]
93
+ }
94
+ },
95
+ {
96
+ files: [
97
+ "test/**/*"
98
+ ],
99
+ rules: {
100
+ "jsdoc/require-jsdoc": "off",
101
+ "@typescript-eslint/dot-notation": "off",
102
+ "@typescript-eslint/no-unsafe-type-assertion": "off"
103
+ }
104
+ }
105
+ );
106
+ export {
107
+ esLintConfigAIDCToolkit
108
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/dev",
3
- "version": "0.9.4",
3
+ "version": "0.9.6-beta",
4
4
  "description": "Shared development artefacts for AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,24 +19,32 @@
19
19
  "url": "https://www.linkedin.com/in/kdean"
20
20
  },
21
21
  "scripts": {
22
- "eslint": "eslint .",
22
+ "copy-workflows": "copy-files-from-to --config copy-workflows.json",
23
+ "lint": "eslint .",
24
+ "release": "tsx src/release.ts",
23
25
  "build": "tsup src/index.ts --format cjs,esm --dts",
24
26
  "build-doc": "npm run build"
25
27
  },
26
28
  "devDependencies": {
27
- "eslint": "^9.15.0",
29
+ "copy-files-from-to": "^3.12.0",
30
+ "eslint": "^9.16.0",
28
31
  "ts-node": "^10.9.2",
29
32
  "tsup": "^8.3.5",
30
- "typescript": "^5.6.3"
33
+ "tsx": "^4.19.2",
34
+ "typescript": "^5.7.2"
31
35
  },
32
36
  "peerDependencies": {
33
37
  "eslint": ">=9"
34
38
  },
35
39
  "dependencies": {
36
- "@eslint/js": "^9.15.0",
37
- "@stylistic/eslint-plugin": "^2.10.1",
38
- "eslint-config-love": "^99.0.0",
39
- "eslint-plugin-jsdoc": "^50.5.0",
40
- "typescript-eslint": "^8.14.0"
40
+ "@eslint/js": "^9.16.0",
41
+ "@octokit/types": "^13.6.2",
42
+ "@rollup/rollup-linux-x64-gnu": "^4.28.0",
43
+ "@stylistic/eslint-plugin": "^2.11.0",
44
+ "eslint-config-love": "^109.0.0",
45
+ "eslint-plugin-jsdoc": "^50.6.0",
46
+ "octokit": "^4.0.2",
47
+ "typescript-eslint": "^8.16.0",
48
+ "yaml": "^2.6.1"
41
49
  }
42
50
  }
@@ -25,6 +25,7 @@ export const esLintConfigAIDCToolkit = tseslint.config(
25
25
  },
26
26
 
27
27
  rules: {
28
+ "complexity": "off",
28
29
  "no-dupe-class-members": "off",
29
30
  "no-redeclare": "off",
30
31
  "no-unused-vars": "off",
@@ -65,6 +66,7 @@ export const esLintConfigAIDCToolkit = tseslint.config(
65
66
  delimiter: "semi"
66
67
  }
67
68
  }],
69
+ "@stylistic/no-trailing-spaces": ["off"],
68
70
  "@stylistic/operator-linebreak": ["error", "after"],
69
71
  "@stylistic/quotes": ["error", "double"],
70
72
  "@stylistic/semi": ["error", "always"],
@@ -101,7 +103,8 @@ export const esLintConfigAIDCToolkit = tseslint.config(
101
103
  ],
102
104
  rules: {
103
105
  "jsdoc/require-jsdoc": "off",
104
- "@typescript-eslint/dot-notation": "off"
106
+ "@typescript-eslint/dot-notation": "off",
107
+ "@typescript-eslint/no-unsafe-type-assertion": "off"
105
108
  }
106
109
  }
107
110
  );
package/src/release.ts ADDED
@@ -0,0 +1,384 @@
1
+ import { spawnSync } from "child_process";
2
+ import * as fs from "fs";
3
+ import * as path from "node:path";
4
+ import { Octokit } from "octokit";
5
+ import { parse as yamlParse } from "yaml";
6
+
7
+ import configurationJSON from "../config/release.json" assert { type: "json" };
8
+ import secureConfigurationJSON from "../config/release.secure.json" assert { type: "json" };
9
+
10
+ /**
11
+ * Configuration layout of release.json.
12
+ */
13
+ interface Configuration {
14
+ /**
15
+ * Organization that owns the repositories.
16
+ */
17
+ organization: string;
18
+
19
+ /**
20
+ * Repositories.
21
+ */
22
+ repositories: Record<string, {
23
+ /**
24
+ * Directory in which repository resides, if different from repository name.
25
+ */
26
+ directory?: string;
27
+
28
+ /**
29
+ * Version for repository. Not all repositories will be in sync with the version.
30
+ */
31
+ version: string;
32
+ }>;
33
+
34
+ /**
35
+ * If true, the fact that the repository is uncommitted is ignored. For development and testing purposes only.
36
+ */
37
+ ignoreUncommitted?: boolean;
38
+ }
39
+
40
+ /**
41
+ * Configuration layout of release.secure.json.
42
+ */
43
+ interface SecureConfiguration {
44
+ token: string;
45
+ }
46
+
47
+ const configuration: Configuration = configurationJSON;
48
+ const secureConfiguration: SecureConfiguration = secureConfigurationJSON;
49
+
50
+ /**
51
+ * Configuration layout of package.json (relevant attributes only).
52
+ */
53
+ interface PackageConfiguration {
54
+ /**
55
+ * Version.
56
+ */
57
+ version: string;
58
+
59
+ /**
60
+ * Development dependencies.
61
+ */
62
+ devDependencies?: Record<string, string>;
63
+
64
+ /**
65
+ * Dependencies.
66
+ */
67
+ dependencies?: Record<string, string>;
68
+ }
69
+
70
+ /**
71
+ * Configuration layout of release.yml workflow (relevant attributes only).
72
+ */
73
+ interface WorkflowConfiguration {
74
+ /**
75
+ * Workflow name.
76
+ */
77
+ name: string;
78
+
79
+ /**
80
+ * Workflow trigger.
81
+ */
82
+ on: {
83
+ /**
84
+ * Push trigger.
85
+ */
86
+ push?: {
87
+ /**
88
+ * Push branches.
89
+ */
90
+ branches?: string[];
91
+ };
92
+
93
+ /**
94
+ * Release trigger.
95
+ */
96
+ release?: {
97
+ /**
98
+ * Release types.
99
+ */
100
+ types?: string[];
101
+ };
102
+ };
103
+ }
104
+
105
+ /**
106
+ * Run a command and optionally capture its output.
107
+ *
108
+ * @param captureOutput
109
+ * If true, output is captured and returned.
110
+ *
111
+ * @param command
112
+ * Command to run.
113
+ *
114
+ * @param args
115
+ * Arguments to command.
116
+ *
117
+ * @returns
118
+ * Output if captured or empty array if not.
119
+ */
120
+ function run(captureOutput: boolean, command: string, ...args: string[]): string[] {
121
+ const spawnResult = spawnSync(command, args, {
122
+ stdio: ["inherit", captureOutput ? "pipe" : "inherit", "inherit"]
123
+ });
124
+
125
+ if (spawnResult.error !== undefined) {
126
+ throw spawnResult.error;
127
+ }
128
+
129
+ if (spawnResult.status === null) {
130
+ throw new Error(`Terminated by signal ${spawnResult.signal}`);
131
+ }
132
+
133
+ if (spawnResult.status !== 0) {
134
+ throw new Error(`Failed with status ${spawnResult.status}`);
135
+ }
136
+
137
+ return captureOutput ? spawnResult.stdout.toString().split("\n").slice(0, -1) : [];
138
+ }
139
+
140
+ /**
141
+ * Release.
142
+ */
143
+ async function release(): Promise<void> {
144
+ const statePath = path.resolve("config/release.state.json");
145
+
146
+ let state: Record<string, string | undefined> = {};
147
+
148
+ if (fs.existsSync(statePath)) {
149
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Format is controlled by this process.
150
+ state = JSON.parse(fs.readFileSync(statePath).toString());
151
+ }
152
+
153
+ /**
154
+ * Save the current state.
155
+ */
156
+ function saveState(): void {
157
+ fs.writeFileSync(statePath, `${JSON.stringify(state, null, 2)}\n`);
158
+ }
159
+
160
+ /**
161
+ * Execute a step.
162
+ *
163
+ * @param name
164
+ * Repository name.
165
+ *
166
+ * @param stepState
167
+ * State at which step takes place.
168
+ *
169
+ * @param callback
170
+ * Callback to execute step.
171
+ *
172
+ * @returns
173
+ * Promise.
174
+ */
175
+ async function step(name: string, stepState: string, callback: () => (void | Promise<void>)): Promise<void> {
176
+ const repositoryState = state[name];
177
+
178
+ if (repositoryState === undefined || repositoryState === stepState) {
179
+ state[name] = stepState;
180
+
181
+ try {
182
+ const result = callback();
183
+
184
+ if (result instanceof Promise) {
185
+ await result;
186
+ }
187
+
188
+ state[name] = undefined;
189
+ } finally {
190
+ fs.writeFileSync(statePath, `${JSON.stringify(state, null, 2)}\n`);
191
+ }
192
+ }
193
+ }
194
+
195
+ const octokit = new Octokit({
196
+ auth: secureConfiguration.token,
197
+ userAgent: `${configuration.organization} release`
198
+ });
199
+
200
+ for (const name of Object.keys(configuration.repositories)) {
201
+ const repository = configuration.repositories[name];
202
+
203
+ console.log(`Repository ${name}...`);
204
+
205
+ // All repositories are expected to be children of the parent of this repository.
206
+ process.chdir(`../${repository.directory ?? name}`);
207
+
208
+ // Repository must be on main branch.
209
+ if (run(true, "git", "branch", "--show-current")[0] !== "main") {
210
+ throw new Error("Repository is not on main branch");
211
+ }
212
+
213
+ // Repository must be fully committed except for untracked files.
214
+ if (!(configuration.ignoreUncommitted ?? false) && state[name] === undefined && run(true, "git", "status", "--short", "--untracked-files=no").length !== 0) {
215
+ throw new Error("Repository has uncommitted changes");
216
+ }
217
+
218
+ const workflowsPath = ".github/workflows/";
219
+
220
+ let hasPushWorkflow = false;
221
+ let hasReleaseWorkflow = false;
222
+
223
+ for (const workflowFile of fs.readdirSync(workflowsPath)) {
224
+ if (workflowFile.endsWith(".yml")) {
225
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Workflow configuration format is known.
226
+ const workflowOn = (yamlParse(fs.readFileSync(path.resolve(workflowsPath, workflowFile)).toString()) as WorkflowConfiguration).on;
227
+
228
+ if (workflowOn.push !== undefined && (workflowOn.push.branches === undefined || workflowOn.push.branches.includes("main"))) {
229
+ hasPushWorkflow = true;
230
+ }
231
+
232
+ if (workflowOn.release !== undefined && (workflowOn.release.types === undefined || workflowOn.release.types.includes("published"))) {
233
+ hasReleaseWorkflow = true;
234
+ }
235
+ }
236
+ }
237
+
238
+ const tag = `v${repository.version}`;
239
+
240
+ const octokitParameterBase = {
241
+ owner: configuration.organization,
242
+ repo: name
243
+ };
244
+
245
+ const commitSHA = run(true, "git", "rev-parse", "HEAD")[0];
246
+
247
+ /**
248
+ * Validate the workflow by waiting for it to complete.
249
+ */
250
+ async function validateWorkflow(): Promise<void> {
251
+ while (!await new Promise<void>((resolve) => {
252
+ setTimeout(resolve, 2000);
253
+ }).then(async () => await octokit.rest.actions.listWorkflowRunsForRepo({
254
+ ...octokitParameterBase,
255
+ head_sha: commitSHA
256
+ })).then((response) => {
257
+ let workflowRunID = -1;
258
+
259
+ let queryCount = 0;
260
+ let completed = false;
261
+
262
+ for (const workflowRun of response.data.workflow_runs) {
263
+ if (workflowRun.status !== "completed") {
264
+ if (workflowRun.id === workflowRunID) {
265
+ process.stdout.write(".");
266
+ } else if (workflowRunID === -1) {
267
+ workflowRunID = workflowRun.id;
268
+
269
+ console.log(`Workflow run ID ${workflowRunID}`);
270
+ } else {
271
+ throw new Error(`Parallel workflow runs for SHA ${commitSHA}`);
272
+ }
273
+ } else if (workflowRun.id === workflowRunID) {
274
+ process.stdout.write("\n");
275
+
276
+ if (workflowRun.conclusion !== "success") {
277
+ throw new Error(`Workflow ${workflowRun.conclusion}`);
278
+ }
279
+
280
+ completed = true;
281
+ }
282
+ }
283
+
284
+ // Abort if workflow run not started after 10 queries.
285
+ if (++queryCount === 10 && workflowRunID === -1) {
286
+ throw new Error(`Workflow run not started for SHA ${commitSHA}`);
287
+ }
288
+
289
+ return completed;
290
+ })) {
291
+ // Execution within conditional.
292
+ }
293
+ }
294
+
295
+ const packageConfigurationPath = "package.json";
296
+
297
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Package configuration format is known.
298
+ const packageConfiguration: PackageConfiguration = JSON.parse(fs.readFileSync(packageConfigurationPath).toString());
299
+
300
+ const skipRepository = state[name] === undefined && packageConfiguration.version === repository.version;
301
+
302
+ if (packageConfiguration.version !== repository.version) {
303
+ packageConfiguration.version = repository.version;
304
+
305
+ const atOrganization = `@${configuration.organization}/`;
306
+
307
+ /**
308
+ * Update dependencies from the organization.
309
+ *
310
+ * @param dependencies
311
+ * Dependencies.
312
+ */
313
+ function updateDependencies(dependencies: Record<string, string> | undefined): void {
314
+ if (dependencies !== undefined) {
315
+ for (const dependency in dependencies) {
316
+ const [dependencyAtOrganization, dependencyRepositoryName] = dependency.split("/");
317
+
318
+ if (dependencyAtOrganization === atOrganization) {
319
+ dependencies[dependency] = `^${configuration.repositories[dependencyRepositoryName].version}`;
320
+ }
321
+ }
322
+ }
323
+ }
324
+
325
+ updateDependencies(packageConfiguration.devDependencies);
326
+ updateDependencies(packageConfiguration.dependencies);
327
+
328
+ fs.writeFileSync(packageConfigurationPath, `${JSON.stringify(packageConfiguration, null, 2)}\n`);
329
+ }
330
+
331
+ if (!skipRepository) {
332
+ await step(name, "npm install", () => {
333
+ run(false, "npm", "install");
334
+ }).then(async () => {
335
+ await step(name, "git commit", () => {
336
+ run(false, "git", "commit", "--all", `--message=Updated to version ${repository.version}`);
337
+ });
338
+ }).then(async () => {
339
+ await step(name, "git tag", () => {
340
+ run(false, "git", "tag", tag);
341
+ });
342
+ }).then(async () => {
343
+ await step(name, "git push", () => {
344
+ run(false, "git", "push", "--atomic", "origin", "main", tag);
345
+ });
346
+ }).then(async () => {
347
+ await step(name, "push workflow", async () => {
348
+ if (hasPushWorkflow) {
349
+ await validateWorkflow();
350
+ }
351
+ });
352
+ }).then(async () => {
353
+ await step(name, "release", async () => {
354
+ const versionSplit = repository.version.split("-");
355
+ const prerelease = versionSplit.length !== 1;
356
+
357
+ await octokit.rest.repos.createRelease({
358
+ ...octokitParameterBase,
359
+ tag_name: tag,
360
+ name: `${prerelease ? `${versionSplit[1].substring(0, 1).toUpperCase()}${versionSplit[1].substring(1)} r` : "R"}elease ${versionSplit[0]}`,
361
+ // TODO Remove "false" override.
362
+ prerelease: false
363
+ });
364
+ });
365
+ }).then(async () => {
366
+ await step(name, "release workflow", async () => {
367
+ if (hasReleaseWorkflow) {
368
+ await validateWorkflow();
369
+ }
370
+ });
371
+ });
372
+
373
+ state[name] = "complete";
374
+ saveState();
375
+ }
376
+ }
377
+
378
+ state = {};
379
+ saveState();
380
+ }
381
+
382
+ await release().catch((e: unknown) => {
383
+ console.error(e);
384
+ });
@@ -1,32 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Describe the bug**
11
- A clear and concise description of what the bug is.
12
-
13
- **To Reproduce**
14
- Steps to reproduce the behavior:
15
- 1. Go to '...'
16
- 2. Click on '....'
17
- 3. Scroll down to '....'
18
- 4. See error
19
-
20
- **Expected behavior**
21
- A clear and concise description of what you expected to happen.
22
-
23
- **Screenshots**
24
- If applicable, add screenshots to help explain your problem.
25
-
26
- **Platform**
27
- - OS: [e.g. Windows, iOS]
28
- - Browser [e.g. chrome, safari]
29
- - Browser Version [e.g. 22]
30
-
31
- **Additional context**
32
- Add any other context about the problem here.
@@ -1,20 +0,0 @@
1
- ---
2
- name: Feature request
3
- about: Suggest an idea for this project
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Is your feature request related to a problem? Please describe.**
11
- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
-
13
- **Describe the solution you'd like**
14
- A clear and concise description of what you want to happen.
15
-
16
- **Describe alternatives you've considered**
17
- A clear and concise description of any alternative solutions or features you've considered.
18
-
19
- **Additional context**
20
- Add any other context or screenshots about the feature request here.
@@ -1,32 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: actions/setup-node@v4
16
- with:
17
- node-version: 22
18
- - run: npm ci
19
-
20
- publish-npm:
21
- needs: build
22
- runs-on: ubuntu-latest
23
- steps:
24
- - uses: actions/checkout@v4
25
- - uses: actions/setup-node@v4
26
- with:
27
- node-version: 22
28
- registry-url: https://registry.npmjs.org/
29
- - run: npm ci
30
- - run: npm publish --access public
31
- env:
32
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}
package/.idea/dev.iml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="JAVA_MODULE" version="4">
3
- <component name="NewModuleRootManager" inherit-compiler-output="true">
4
- <exclude-output />
5
- <content url="file://$MODULE_DIR$" />
6
- <orderEntry type="inheritedJdk" />
7
- <orderEntry type="sourceFolder" forTests="false" />
8
- </component>
9
- </module>
@@ -1,7 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- <inspection_tool class="UpdateDependencyToLatestVersion" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
6
- </profile>
7
- </component>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
4
- <output url="file://$PROJECT_DIR$/out" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/dev.iml" filepath="$PROJECT_DIR$/.idea/dev.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,12 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="build" type="js.build_tools.npm" nameIsGenerated="true">
3
- <package-json value="$PROJECT_DIR$/package.json" />
4
- <command value="run" />
5
- <scripts>
6
- <script value="build" />
7
- </scripts>
8
- <node-interpreter value="project" />
9
- <envs />
10
- <method v="2" />
11
- </configuration>
12
- </component>
@@ -1,12 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="eslint" type="js.build_tools.npm" nameIsGenerated="true">
3
- <package-json value="$PROJECT_DIR$/package.json" />
4
- <command value="run" />
5
- <scripts>
6
- <script value="eslint" />
7
- </scripts>
8
- <node-interpreter value="project" />
9
- <envs />
10
- <method v="2" />
11
- </configuration>
12
- </component>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>