@aidc-toolkit/dev 0.9.16-beta → 0.9.17-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.
- package/config/publish.json +53 -0
- package/dev.iml +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{command-util.d.ts → utility.d.ts} +6 -1
- package/dist/utility.d.ts.map +1 -0
- package/dist/utility.js +57 -0
- package/dist/utility.js.map +1 -0
- package/eslint.config.ts +1 -1
- package/package.json +4 -6
- package/src/index.ts +1 -1
- package/src/publish-external.ts +332 -0
- package/src/publish-internal.ts +111 -0
- package/src/publish.ts +273 -0
- package/src/{command-util.ts → utility.ts} +24 -1
- package/tsconfig-build-dev-local.json +1 -0
- package/tsconfig-build-dev.json +1 -0
- package/tsconfig.json +7 -0
- package/bin/publish-dev +0 -8
- package/bin/publish-dev-local +0 -8
- package/config/release.json +0 -30
- package/dist/command-util.d.ts.map +0 -1
- package/dist/command-util.js +0 -32
- package/dist/command-util.js.map +0 -1
- package/dist/publish-dev.d.ts +0 -5
- package/dist/publish-dev.d.ts.map +0 -1
- package/dist/publish-dev.js +0 -72
- package/dist/publish-dev.js.map +0 -1
- package/src/publish-dev.ts +0 -110
- package/src/release.ts +0 -428
package/src/publish.ts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import configurationJSON from "../config/publish.json";
|
|
4
|
+
import secureConfigurationJSON from "../config/publish.secure.json";
|
|
5
|
+
import { logger, run } from "./utility";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Repository.
|
|
9
|
+
*/
|
|
10
|
+
export interface Repository {
|
|
11
|
+
/**
|
|
12
|
+
* Directory in which repository resides, if different from repository name.
|
|
13
|
+
*/
|
|
14
|
+
directory?: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Dependency type, dictating how it is published.
|
|
18
|
+
*/
|
|
19
|
+
dependencyType: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Files excluded from consideration when checking for changes.
|
|
23
|
+
*/
|
|
24
|
+
excludeFiles?: string[];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Date/time the package was last published internally in ISO format.
|
|
28
|
+
*/
|
|
29
|
+
lastInternalPublished?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Date/time the package was last published externally in ISO format.
|
|
33
|
+
*/
|
|
34
|
+
lastExternalPublished?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Last external published version.
|
|
38
|
+
*/
|
|
39
|
+
lastExternalVersion?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Current step in external publication; used to resume after failure recovery.
|
|
43
|
+
*/
|
|
44
|
+
publishExternalStep?: string | undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Configuration layout of publish.json.
|
|
49
|
+
*/
|
|
50
|
+
export interface Configuration {
|
|
51
|
+
/**
|
|
52
|
+
* Organization that owns the repositories.
|
|
53
|
+
*/
|
|
54
|
+
organization: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Repositories.
|
|
58
|
+
*/
|
|
59
|
+
repositories: Record<string, Repository>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Configuration layout of publish.secure.json.
|
|
64
|
+
*/
|
|
65
|
+
interface SecureConfiguration {
|
|
66
|
+
token: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Configuration layout of package.json (relevant attributes only).
|
|
71
|
+
*/
|
|
72
|
+
export interface PackageConfiguration {
|
|
73
|
+
/**
|
|
74
|
+
* Name.
|
|
75
|
+
*/
|
|
76
|
+
name: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Version.
|
|
80
|
+
*/
|
|
81
|
+
version: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Development dependencies.
|
|
85
|
+
*/
|
|
86
|
+
devDependencies?: Record<string, string>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Dependencies.
|
|
90
|
+
*/
|
|
91
|
+
dependencies?: Record<string, string>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const configuration: Configuration = configurationJSON;
|
|
95
|
+
export const secureConfiguration: SecureConfiguration = secureConfigurationJSON;
|
|
96
|
+
|
|
97
|
+
const atOrganization = `@${configuration.organization}`;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get the organization repository name or a dependency if it belongs to the organization or null if not.
|
|
101
|
+
*
|
|
102
|
+
* @param dependency
|
|
103
|
+
* Dependency.
|
|
104
|
+
*
|
|
105
|
+
* @returns
|
|
106
|
+
* Organization repository name or null.
|
|
107
|
+
*/
|
|
108
|
+
export function organizationRepository(dependency: string): string | null {
|
|
109
|
+
const [dependencyAtOrganization, dependencyRepositoryName] = dependency.split("/");
|
|
110
|
+
|
|
111
|
+
return dependencyAtOrganization === atOrganization ? dependencyRepositoryName : null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Determine if there have been any changes to a repository.
|
|
116
|
+
*
|
|
117
|
+
* @param repository
|
|
118
|
+
* Repository configuration.
|
|
119
|
+
*
|
|
120
|
+
* @param external
|
|
121
|
+
* False if comparing to the last internal published date/time, true if comparing to the last external published
|
|
122
|
+
* date/time.
|
|
123
|
+
*
|
|
124
|
+
* @returns
|
|
125
|
+
* True if there is no last published date/time or if there have been any changes since then.
|
|
126
|
+
*/
|
|
127
|
+
export function anyChanges(repository: Repository, external: boolean): boolean {
|
|
128
|
+
let anyChanges: boolean;
|
|
129
|
+
|
|
130
|
+
const lastPublishedString = !external ? repository.lastInternalPublished : repository.lastExternalPublished;
|
|
131
|
+
|
|
132
|
+
const changedFilesSet = new Set<string>();
|
|
133
|
+
|
|
134
|
+
if (lastPublishedString !== undefined) {
|
|
135
|
+
for (const line of run(true, "git", "log", `--since="${lastPublishedString}"`, "--name-status", "--pretty=oneline")) {
|
|
136
|
+
// Header starts with 40-character SHA.
|
|
137
|
+
if (!/^[0-9a-f]{40} /.test(line)) {
|
|
138
|
+
const [status, file] = line.split("\t");
|
|
139
|
+
|
|
140
|
+
// Ignore deleted files; anything that depends on a deleted file will have been modified.
|
|
141
|
+
if (status !== "D") {
|
|
142
|
+
logger.debug(`+File: ${file}`);
|
|
143
|
+
|
|
144
|
+
changedFilesSet.add(file);
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
logger.debug(`Commit SHA ${line.substring(0, 40)}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (lastPublishedString !== undefined || external) {
|
|
153
|
+
const output = run(true, "git", "status", "--porcelain");
|
|
154
|
+
|
|
155
|
+
if (output.length !== 0) {
|
|
156
|
+
if (external) {
|
|
157
|
+
throw new Error("Repository has uncommitted changes");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
logger.debug("Uncommitted");
|
|
161
|
+
|
|
162
|
+
for (const line of output) {
|
|
163
|
+
// Line is two-character status, space, and detail.
|
|
164
|
+
const status = line.substring(0, 2);
|
|
165
|
+
const detail = line.substring(3);
|
|
166
|
+
|
|
167
|
+
// Ignore deleted files; anything that depends on a deleted file will have been modified.
|
|
168
|
+
if (status !== "D ") {
|
|
169
|
+
let file: string;
|
|
170
|
+
|
|
171
|
+
if (status.startsWith("R")) {
|
|
172
|
+
// File has been renamed; get old and new file names.
|
|
173
|
+
const [oldFile, newFile] = detail.split(" -> ");
|
|
174
|
+
|
|
175
|
+
logger.debug(`-File: ${oldFile}`);
|
|
176
|
+
|
|
177
|
+
changedFilesSet.delete(oldFile);
|
|
178
|
+
|
|
179
|
+
file = newFile;
|
|
180
|
+
} else {
|
|
181
|
+
file = detail;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
logger.debug(`+File: ${file}`);
|
|
185
|
+
|
|
186
|
+
changedFilesSet.add(file);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (lastPublishedString !== undefined) {
|
|
193
|
+
logger.debug("Excluded");
|
|
194
|
+
|
|
195
|
+
const hiddenFiles = [];
|
|
196
|
+
|
|
197
|
+
// Get list of hidden files and directories.
|
|
198
|
+
for (const changedFile of changedFilesSet) {
|
|
199
|
+
if (changedFile.startsWith(".") || changedFile.includes("/.")) {
|
|
200
|
+
hiddenFiles.push(changedFile);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Exclude hidden files and directories.
|
|
205
|
+
for (const hiddenFile of hiddenFiles) {
|
|
206
|
+
logger.debug(`-File: ${hiddenFile}`);
|
|
207
|
+
|
|
208
|
+
changedFilesSet.delete(hiddenFile);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (repository.excludeFiles !== undefined) {
|
|
212
|
+
for (const excludeFile of repository.excludeFiles) {
|
|
213
|
+
if (changedFilesSet.delete(excludeFile)) {
|
|
214
|
+
logger.debug(`-File: ${excludeFile}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
logger.info("Changed");
|
|
220
|
+
|
|
221
|
+
const lastPublished = new Date(lastPublishedString);
|
|
222
|
+
|
|
223
|
+
anyChanges = false;
|
|
224
|
+
|
|
225
|
+
for (const changedFile of changedFilesSet) {
|
|
226
|
+
if (fs.lstatSync(changedFile).mtime > lastPublished) {
|
|
227
|
+
logger.info(`File: ${changedFile}`);
|
|
228
|
+
|
|
229
|
+
anyChanges = true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
// No last published, so there must have been changes.
|
|
234
|
+
anyChanges = true;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (!anyChanges) {
|
|
238
|
+
logger.debug("No changes");
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return anyChanges;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Configuration may be written from any directory so full path is required.
|
|
245
|
+
const configurationPath = path.resolve("config/publish.json");
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Save the current configuration.
|
|
249
|
+
*/
|
|
250
|
+
export function saveConfiguration(): void {
|
|
251
|
+
fs.writeFileSync(configurationPath, `${JSON.stringify(configuration, null, 2)}\n`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Publish all repositories.
|
|
256
|
+
*
|
|
257
|
+
* @param callback
|
|
258
|
+
* Callback taking the name and properties of the repository to publish.
|
|
259
|
+
*/
|
|
260
|
+
export async function publishRepositories(callback: (name: string, repository: Repository) => void | Promise<void>): Promise<void> {
|
|
261
|
+
logger.settings.minLevel = 2;
|
|
262
|
+
|
|
263
|
+
for (const [name, repository] of Object.entries(configuration.repositories)) {
|
|
264
|
+
logger.info(`Repository ${name}...`);
|
|
265
|
+
|
|
266
|
+
// All repositories are expected to be children of the parent of this repository.
|
|
267
|
+
process.chdir(`../${repository.directory ?? name}`);
|
|
268
|
+
|
|
269
|
+
await callback(name, repository);
|
|
270
|
+
|
|
271
|
+
saveConfiguration();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { spawnSync } from "child_process";
|
|
2
|
+
import { Logger } from "tslog";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Log level.
|
|
6
|
+
*/
|
|
7
|
+
enum LogLevel {
|
|
8
|
+
Silly, Trace, Debug, Info, Warn, Error, Fatal
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Logger with a default minimum level of Info.
|
|
13
|
+
*/
|
|
14
|
+
export const logger = new Logger({
|
|
15
|
+
minLevel: LogLevel.Info
|
|
16
|
+
});
|
|
2
17
|
|
|
3
18
|
/**
|
|
4
19
|
* Run a command and optionally capture its output.
|
|
@@ -16,6 +31,8 @@ import { spawnSync } from "child_process";
|
|
|
16
31
|
* Output if captured or empty array if not.
|
|
17
32
|
*/
|
|
18
33
|
export function run(captureOutput: boolean, command: string, ...args: string[]): string[] {
|
|
34
|
+
logger.debug(`Running command "${command}" with arguments ${JSON.stringify(args)}.`);
|
|
35
|
+
|
|
19
36
|
const spawnResult = spawnSync(command, args, {
|
|
20
37
|
stdio: ["inherit", captureOutput ? "pipe" : "inherit", "inherit"]
|
|
21
38
|
});
|
|
@@ -32,5 +49,11 @@ export function run(captureOutput: boolean, command: string, ...args: string[]):
|
|
|
32
49
|
throw new Error(`Failed with status ${spawnResult.status}`);
|
|
33
50
|
}
|
|
34
51
|
|
|
35
|
-
|
|
52
|
+
const output = captureOutput ? spawnResult.stdout.toString().split("\n").slice(0, -1) : [];
|
|
53
|
+
|
|
54
|
+
if (captureOutput) {
|
|
55
|
+
logger.debug(`Output is ${JSON.stringify(output)}.`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return output;
|
|
36
59
|
}
|
package/tsconfig-build-dev.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
+
// https://aka.ms/tsconfig
|
|
1
2
|
{
|
|
2
3
|
"compilerOptions": {
|
|
4
|
+
// Type checking.
|
|
3
5
|
"strict": true,
|
|
4
6
|
"exactOptionalPropertyTypes": true,
|
|
5
7
|
"noFallthroughCasesInSwitch": true,
|
|
6
8
|
"noImplicitOverride": true,
|
|
7
9
|
"noPropertyAccessFromIndexSignature": true,
|
|
8
10
|
|
|
11
|
+
// Modules.
|
|
9
12
|
"module": "ES2022",
|
|
10
13
|
"moduleResolution": "bundler",
|
|
11
14
|
"resolveJsonModule": true,
|
|
12
15
|
|
|
16
|
+
// Emit.
|
|
13
17
|
"declaration": true,
|
|
14
18
|
|
|
19
|
+
// Interop constraints.
|
|
15
20
|
"esModuleInterop": true,
|
|
16
21
|
"forceConsistentCasingInFileNames": true,
|
|
17
22
|
|
|
23
|
+
// Language and environment.
|
|
18
24
|
"target": "ES2022",
|
|
19
25
|
|
|
26
|
+
// Completeness.
|
|
20
27
|
"skipLibCheck": true
|
|
21
28
|
}
|
|
22
29
|
}
|
package/bin/publish-dev
DELETED
package/bin/publish-dev-local
DELETED
package/config/release.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"organization": "aidc-toolkit",
|
|
3
|
-
"repositories": {
|
|
4
|
-
"dev": {
|
|
5
|
-
"version": "0.9.16-beta"
|
|
6
|
-
},
|
|
7
|
-
"core": {
|
|
8
|
-
"version": "0.9.16-beta"
|
|
9
|
-
},
|
|
10
|
-
"utility": {
|
|
11
|
-
"version": "0.9.16-beta"
|
|
12
|
-
},
|
|
13
|
-
"gs1": {
|
|
14
|
-
"version": "0.9.16-beta"
|
|
15
|
-
},
|
|
16
|
-
"demo": {
|
|
17
|
-
"version": "0.9.16-beta"
|
|
18
|
-
},
|
|
19
|
-
"app-extension": {
|
|
20
|
-
"version": "0.9.16-beta"
|
|
21
|
-
},
|
|
22
|
-
"app-generator": {
|
|
23
|
-
"version": "0.9.16-beta"
|
|
24
|
-
},
|
|
25
|
-
"aidc-toolkit.github.io": {
|
|
26
|
-
"directory": "doc",
|
|
27
|
-
"version": "0.9.16-beta"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command-util.d.ts","sourceRoot":"","sources":["../src/command-util.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAkBxF"}
|
package/dist/command-util.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "child_process";
|
|
2
|
-
/**
|
|
3
|
-
* Run a command and optionally capture its output.
|
|
4
|
-
*
|
|
5
|
-
* @param captureOutput
|
|
6
|
-
* If true, output is captured and returned.
|
|
7
|
-
*
|
|
8
|
-
* @param command
|
|
9
|
-
* Command to run.
|
|
10
|
-
*
|
|
11
|
-
* @param args
|
|
12
|
-
* Arguments to command.
|
|
13
|
-
*
|
|
14
|
-
* @returns
|
|
15
|
-
* Output if captured or empty array if not.
|
|
16
|
-
*/
|
|
17
|
-
export function run(captureOutput, command, ...args) {
|
|
18
|
-
const spawnResult = spawnSync(command, args, {
|
|
19
|
-
stdio: ["inherit", captureOutput ? "pipe" : "inherit", "inherit"]
|
|
20
|
-
});
|
|
21
|
-
if (spawnResult.error !== undefined) {
|
|
22
|
-
throw spawnResult.error;
|
|
23
|
-
}
|
|
24
|
-
if (spawnResult.status === null) {
|
|
25
|
-
throw new Error(`Terminated by signal ${spawnResult.signal}`);
|
|
26
|
-
}
|
|
27
|
-
if (spawnResult.status !== 0) {
|
|
28
|
-
throw new Error(`Failed with status ${spawnResult.status}`);
|
|
29
|
-
}
|
|
30
|
-
return captureOutput ? spawnResult.stdout.toString().split("\n").slice(0, -1) : [];
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=command-util.js.map
|
package/dist/command-util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command-util.js","sourceRoot":"","sources":["../src/command-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,GAAG,CAAC,aAAsB,EAAE,OAAe,EAAE,GAAG,IAAc;IAC1E,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE;QACzC,KAAK,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC;KACpE,CAAC,CAAC;IAEH,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,WAAW,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,wBAAwB,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,sBAAsB,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvF,CAAC"}
|
package/dist/publish-dev.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publish-dev.d.ts","sourceRoot":"","sources":["../src/publish-dev.ts"],"names":[],"mappings":"AA+DA;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CA2CjC"}
|
package/dist/publish-dev.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import { run } from "./command-util.js";
|
|
3
|
-
/**
|
|
4
|
-
* Convert a number to a zero-padded string.
|
|
5
|
-
*
|
|
6
|
-
* @param n
|
|
7
|
-
* Number.
|
|
8
|
-
*
|
|
9
|
-
* @param length
|
|
10
|
-
* Length of required string.
|
|
11
|
-
*
|
|
12
|
-
* @returns
|
|
13
|
-
* Zero-padded string.
|
|
14
|
-
*/
|
|
15
|
-
function zeroPadded(n, length) {
|
|
16
|
-
return `${"0".repeat(length - 1)}${n}`.slice(-length);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Fix alpha dependencies from the organization.
|
|
20
|
-
*
|
|
21
|
-
* @param atOrganization
|
|
22
|
-
* '@' symbol and organization.
|
|
23
|
-
* @param dependencies
|
|
24
|
-
* Dependencies.
|
|
25
|
-
*/
|
|
26
|
-
function fixAlphaDependencies(atOrganization, dependencies) {
|
|
27
|
-
if (dependencies !== undefined) {
|
|
28
|
-
for (const dependency in dependencies) {
|
|
29
|
-
if (dependency.split("/")[0] === atOrganization) {
|
|
30
|
-
// npm update --save updates this with the latest.
|
|
31
|
-
dependencies[dependency] = "alpha";
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Publish to development npm registry.
|
|
38
|
-
*/
|
|
39
|
-
export function publishDev() {
|
|
40
|
-
// Ensure that packages are up to date.
|
|
41
|
-
run(false, "npm", "update", "--save");
|
|
42
|
-
const now = new Date();
|
|
43
|
-
const packageConfigurationPath = "package.json";
|
|
44
|
-
const backupPackageConfigurationPath = "_package.json";
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Package configuration format is known.
|
|
46
|
-
const packageConfiguration = JSON.parse(fs.readFileSync(packageConfigurationPath).toString());
|
|
47
|
-
const atOrganization = packageConfiguration.name.split("/")[0];
|
|
48
|
-
fixAlphaDependencies(atOrganization, packageConfiguration.devDependencies);
|
|
49
|
-
fixAlphaDependencies(atOrganization, packageConfiguration.dependencies);
|
|
50
|
-
// Save the package configuration.
|
|
51
|
-
fs.writeFileSync(packageConfigurationPath, `${JSON.stringify(packageConfiguration, null, 2)}\n`);
|
|
52
|
-
// Backup the package configuration file.
|
|
53
|
-
fs.renameSync(packageConfigurationPath, backupPackageConfigurationPath);
|
|
54
|
-
try {
|
|
55
|
-
// Strip pre-release identifier if any and parse semantic version into its components.
|
|
56
|
-
const [majorVersion, minorVersion, patchVersion] = packageConfiguration.version.split("-")[0].split(".").map(versionString => Number(versionString));
|
|
57
|
-
// Set version to alpha version with incremental patch version number.
|
|
58
|
-
packageConfiguration.version = `${majorVersion}.${minorVersion}.${patchVersion + 1}-alpha.${now.getFullYear()}${zeroPadded(now.getMonth() + 1, 2)}${zeroPadded(now.getDate(), 2)}${zeroPadded(now.getHours(), 2)}${zeroPadded(now.getMinutes(), 2)}`;
|
|
59
|
-
// Save the package configuration.
|
|
60
|
-
fs.writeFileSync(packageConfigurationPath, `${JSON.stringify(packageConfiguration, null, 2)}\n`);
|
|
61
|
-
// Run the development build.
|
|
62
|
-
run(false, "npm", "run", "build:dev");
|
|
63
|
-
// Publish to the registry.
|
|
64
|
-
run(false, "npm", "publish", "--tag", "alpha");
|
|
65
|
-
}
|
|
66
|
-
finally {
|
|
67
|
-
// Restore the package configuration file.
|
|
68
|
-
fs.rmSync(packageConfigurationPath);
|
|
69
|
-
fs.renameSync(backupPackageConfigurationPath, packageConfigurationPath);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=publish-dev.js.map
|
package/dist/publish-dev.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publish-dev.js","sourceRoot":"","sources":["../src/publish-dev.ts"],"names":[],"mappings":"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"}
|
package/src/publish-dev.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import { run } from "./command-util.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configuration layout of package.json (relevant attributes only).
|
|
6
|
-
*/
|
|
7
|
-
interface PackageConfiguration {
|
|
8
|
-
/**
|
|
9
|
-
* Name.
|
|
10
|
-
*/
|
|
11
|
-
name: string;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Version.
|
|
15
|
-
*/
|
|
16
|
-
version: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Development dependencies.
|
|
20
|
-
*/
|
|
21
|
-
devDependencies?: Record<string, string>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Dependencies.
|
|
25
|
-
*/
|
|
26
|
-
dependencies?: Record<string, string>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Convert a number to a zero-padded string.
|
|
31
|
-
*
|
|
32
|
-
* @param n
|
|
33
|
-
* Number.
|
|
34
|
-
*
|
|
35
|
-
* @param length
|
|
36
|
-
* Length of required string.
|
|
37
|
-
*
|
|
38
|
-
* @returns
|
|
39
|
-
* Zero-padded string.
|
|
40
|
-
*/
|
|
41
|
-
function zeroPadded(n: number, length: number): string {
|
|
42
|
-
return `${"0".repeat(length - 1)}${n}`.slice(-length);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Fix alpha dependencies from the organization.
|
|
47
|
-
*
|
|
48
|
-
* @param atOrganization
|
|
49
|
-
* '@' symbol and organization.
|
|
50
|
-
* @param dependencies
|
|
51
|
-
* Dependencies.
|
|
52
|
-
*/
|
|
53
|
-
function fixAlphaDependencies(atOrganization: string, dependencies: Record<string, string> | undefined): void {
|
|
54
|
-
if (dependencies !== undefined) {
|
|
55
|
-
for (const dependency in dependencies) {
|
|
56
|
-
if (dependency.split("/")[0] === atOrganization) {
|
|
57
|
-
// npm update --save updates this with the latest.
|
|
58
|
-
dependencies[dependency] = "alpha";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Publish to development npm registry.
|
|
66
|
-
*/
|
|
67
|
-
export function publishDev(): void {
|
|
68
|
-
// Ensure that packages are up to date.
|
|
69
|
-
run(false, "npm", "update", "--save");
|
|
70
|
-
|
|
71
|
-
const now = new Date();
|
|
72
|
-
|
|
73
|
-
const packageConfigurationPath = "package.json";
|
|
74
|
-
const backupPackageConfigurationPath = "_package.json";
|
|
75
|
-
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Package configuration format is known.
|
|
77
|
-
const packageConfiguration: PackageConfiguration = JSON.parse(fs.readFileSync(packageConfigurationPath).toString());
|
|
78
|
-
|
|
79
|
-
const atOrganization = packageConfiguration.name.split("/")[0];
|
|
80
|
-
|
|
81
|
-
fixAlphaDependencies(atOrganization, packageConfiguration.devDependencies);
|
|
82
|
-
fixAlphaDependencies(atOrganization, packageConfiguration.dependencies);
|
|
83
|
-
|
|
84
|
-
// Save the package configuration.
|
|
85
|
-
fs.writeFileSync(packageConfigurationPath, `${JSON.stringify(packageConfiguration, null, 2)}\n`);
|
|
86
|
-
|
|
87
|
-
// Backup the package configuration file.
|
|
88
|
-
fs.renameSync(packageConfigurationPath, backupPackageConfigurationPath);
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
// Strip pre-release identifier if any and parse semantic version into its components.
|
|
92
|
-
const [majorVersion, minorVersion, patchVersion] = packageConfiguration.version.split("-")[0].split(".").map(versionString => Number(versionString));
|
|
93
|
-
|
|
94
|
-
// Set version to alpha version with incremental patch version number.
|
|
95
|
-
packageConfiguration.version = `${majorVersion}.${minorVersion}.${patchVersion + 1}-alpha.${now.getFullYear()}${zeroPadded(now.getMonth() + 1, 2)}${zeroPadded(now.getDate(), 2)}${zeroPadded(now.getHours(), 2)}${zeroPadded(now.getMinutes(), 2)}`;
|
|
96
|
-
|
|
97
|
-
// Save the package configuration.
|
|
98
|
-
fs.writeFileSync(packageConfigurationPath, `${JSON.stringify(packageConfiguration, null, 2)}\n`);
|
|
99
|
-
|
|
100
|
-
// Run the development build.
|
|
101
|
-
run(false, "npm", "run", "build:dev");
|
|
102
|
-
|
|
103
|
-
// Publish to the registry.
|
|
104
|
-
run(false, "npm", "publish", "--tag", "alpha");
|
|
105
|
-
} finally {
|
|
106
|
-
// Restore the package configuration file.
|
|
107
|
-
fs.rmSync(packageConfigurationPath);
|
|
108
|
-
fs.renameSync(backupPackageConfigurationPath, packageConfigurationPath);
|
|
109
|
-
}
|
|
110
|
-
}
|