@aidc-toolkit/dev 0.9.6-beta → 0.9.6

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.
@@ -2,24 +2,24 @@
2
2
  "organization": "aidc-toolkit",
3
3
  "repositories": {
4
4
  "dev": {
5
- "version": "0.9.6-beta"
5
+ "version": "0.9.6"
6
6
  },
7
7
  "core": {
8
- "version": "0.9.6-beta"
8
+ "version": "0.9.6"
9
9
  },
10
10
  "utility": {
11
- "version": "0.9.6-beta"
11
+ "version": "0.9.6"
12
12
  },
13
13
  "gs1": {
14
14
  "name": "gs1",
15
- "version": "0.9.6-beta"
15
+ "version": "0.9.6"
16
16
  },
17
17
  "demo": {
18
- "version": "0.9.6-beta"
18
+ "version": "0.9.6"
19
19
  },
20
20
  "aidc-toolkit.github.io": {
21
21
  "directory": "doc",
22
- "version": "0.9.6-beta"
22
+ "version": "0.9.6"
23
23
  }
24
24
  }
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/dev",
3
- "version": "0.9.6-beta",
3
+ "version": "0.9.6",
4
4
  "description": "Shared development artefacts for AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "scripts": {
22
22
  "copy-workflows": "copy-files-from-to --config copy-workflows.json",
23
23
  "lint": "eslint .",
24
- "release": "tsx src/release.ts",
24
+ "publish": "tsx src/publish.ts",
25
25
  "build": "tsup src/index.ts --format cjs,esm --dts",
26
26
  "build-doc": "npm run build"
27
27
  },
@@ -4,11 +4,11 @@ import * as path from "node:path";
4
4
  import { Octokit } from "octokit";
5
5
  import { parse as yamlParse } from "yaml";
6
6
 
7
- import configurationJSON from "../config/release.json" assert { type: "json" };
8
- import secureConfigurationJSON from "../config/release.secure.json" assert { type: "json" };
7
+ import configurationJSON from "../config/publish.json" assert { type: "json" };
8
+ import secureConfigurationJSON from "../config/publish.secure.json" assert { type: "json" };
9
9
 
10
10
  /**
11
- * Configuration layout of release.json.
11
+ * Configuration layout of publish.json.
12
12
  */
13
13
  interface Configuration {
14
14
  /**
@@ -38,7 +38,7 @@ interface Configuration {
38
38
  }
39
39
 
40
40
  /**
41
- * Configuration layout of release.secure.json.
41
+ * Configuration layout of publish.secure.json.
42
42
  */
43
43
  interface SecureConfiguration {
44
44
  token: string;
@@ -138,23 +138,23 @@ function run(captureOutput: boolean, command: string, ...args: string[]): string
138
138
  }
139
139
 
140
140
  /**
141
- * Release.
141
+ * Publish.
142
142
  */
143
- async function release(): Promise<void> {
144
- const statePath = path.resolve("config/release.state.json");
143
+ async function publish(): Promise<void> {
144
+ const statePath = path.resolve("config/publish.state.json");
145
145
 
146
- let state: Record<string, string | undefined> = {};
146
+ let repositoryStates: Record<string, string | undefined> = {};
147
147
 
148
148
  if (fs.existsSync(statePath)) {
149
149
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Format is controlled by this process.
150
- state = JSON.parse(fs.readFileSync(statePath).toString());
150
+ repositoryStates = JSON.parse(fs.readFileSync(statePath).toString());
151
151
  }
152
152
 
153
153
  /**
154
154
  * Save the current state.
155
155
  */
156
156
  function saveState(): void {
157
- fs.writeFileSync(statePath, `${JSON.stringify(state, null, 2)}\n`);
157
+ fs.writeFileSync(statePath, `${JSON.stringify(repositoryStates, null, 2)}\n`);
158
158
  }
159
159
 
160
160
  /**
@@ -163,7 +163,7 @@ async function release(): Promise<void> {
163
163
  * @param name
164
164
  * Repository name.
165
165
  *
166
- * @param stepState
166
+ * @param state
167
167
  * State at which step takes place.
168
168
  *
169
169
  * @param callback
@@ -172,11 +172,11 @@ async function release(): Promise<void> {
172
172
  * @returns
173
173
  * Promise.
174
174
  */
175
- async function step(name: string, stepState: string, callback: () => (void | Promise<void>)): Promise<void> {
176
- const repositoryState = state[name];
175
+ async function step(name: string, state: string, callback: () => (void | Promise<void>)): Promise<void> {
176
+ const repositoryState = repositoryStates[name];
177
177
 
178
- if (repositoryState === undefined || repositoryState === stepState) {
179
- state[name] = stepState;
178
+ if (repositoryState === undefined || repositoryState === state) {
179
+ repositoryStates[name] = state;
180
180
 
181
181
  try {
182
182
  const result = callback();
@@ -185,16 +185,16 @@ async function release(): Promise<void> {
185
185
  await result;
186
186
  }
187
187
 
188
- state[name] = undefined;
188
+ repositoryStates[name] = undefined;
189
189
  } finally {
190
- fs.writeFileSync(statePath, `${JSON.stringify(state, null, 2)}\n`);
190
+ fs.writeFileSync(statePath, `${JSON.stringify(repositoryStates, null, 2)}\n`);
191
191
  }
192
192
  }
193
193
  }
194
194
 
195
195
  const octokit = new Octokit({
196
196
  auth: secureConfiguration.token,
197
- userAgent: `${configuration.organization} release`
197
+ userAgent: `${configuration.organization} publisher`
198
198
  });
199
199
 
200
200
  for (const name of Object.keys(configuration.repositories)) {
@@ -211,7 +211,7 @@ async function release(): Promise<void> {
211
211
  }
212
212
 
213
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) {
214
+ if (!(configuration.ignoreUncommitted ?? false) && repositoryStates[name] === undefined && run(true, "git", "status", "--short", "--untracked-files=no").length !== 0) {
215
215
  throw new Error("Repository has uncommitted changes");
216
216
  }
217
217
 
@@ -297,7 +297,7 @@ async function release(): Promise<void> {
297
297
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Package configuration format is known.
298
298
  const packageConfiguration: PackageConfiguration = JSON.parse(fs.readFileSync(packageConfigurationPath).toString());
299
299
 
300
- const skipRepository = state[name] === undefined && packageConfiguration.version === repository.version;
300
+ const skipRepository = repositoryStates[name] === undefined && packageConfiguration.version === repository.version;
301
301
 
302
302
  if (packageConfiguration.version !== repository.version) {
303
303
  packageConfiguration.version = repository.version;
@@ -358,8 +358,7 @@ async function release(): Promise<void> {
358
358
  ...octokitParameterBase,
359
359
  tag_name: tag,
360
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
361
+ prerelease
363
362
  });
364
363
  });
365
364
  }).then(async () => {
@@ -370,15 +369,15 @@ async function release(): Promise<void> {
370
369
  });
371
370
  });
372
371
 
373
- state[name] = "complete";
372
+ repositoryStates[name] = "complete";
374
373
  saveState();
375
374
  }
376
375
  }
377
376
 
378
- state = {};
377
+ repositoryStates = {};
379
378
  saveState();
380
379
  }
381
380
 
382
- await release().catch((e: unknown) => {
381
+ await publish().catch((e: unknown) => {
383
382
  console.error(e);
384
383
  });