@aidc-toolkit/dev 0.9.16-beta → 0.9.18-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 +60 -0
- package/dev.iml +9 -0
- package/dist/eslint-config-template.d.ts.map +1 -1
- package/dist/eslint-config-template.js +9 -2
- package/dist/eslint-config-template.js.map +1 -1
- 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 +58 -0
- package/dist/utility.js.map +1 -0
- package/eslint.config.ts +1 -1
- package/package.json +15 -17
- package/src/eslint-config-template.ts +10 -2
- package/src/index.ts +1 -1
- package/src/publish-external.ts +362 -0
- package/src/publish-internal.ts +174 -0
- package/src/publish.ts +287 -0
- package/src/{command-util.ts → utility.ts} +25 -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,287 @@
|
|
|
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
|
+
* If true, publish repository externally always.
|
|
33
|
+
*/
|
|
34
|
+
publishExternalAlways?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Date/time the package was last published externally in ISO format.
|
|
38
|
+
*/
|
|
39
|
+
lastExternalPublished?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Last external published version.
|
|
43
|
+
*/
|
|
44
|
+
lastExternalVersion?: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Current step in external publication; used to resume after failure recovery.
|
|
48
|
+
*/
|
|
49
|
+
publishExternalStep?: string | undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Configuration layout of publish.json.
|
|
54
|
+
*/
|
|
55
|
+
export interface Configuration {
|
|
56
|
+
/**
|
|
57
|
+
* Organization that owns the repositories.
|
|
58
|
+
*/
|
|
59
|
+
organization: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Repositories.
|
|
63
|
+
*/
|
|
64
|
+
repositories: Record<string, Repository>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Configuration layout of publish.secure.json.
|
|
69
|
+
*/
|
|
70
|
+
interface SecureConfiguration {
|
|
71
|
+
token: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Configuration layout of package.json (relevant attributes only).
|
|
76
|
+
*/
|
|
77
|
+
export interface PackageConfiguration {
|
|
78
|
+
/**
|
|
79
|
+
* Name.
|
|
80
|
+
*/
|
|
81
|
+
name: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Version.
|
|
85
|
+
*/
|
|
86
|
+
version: string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Development dependencies.
|
|
90
|
+
*/
|
|
91
|
+
devDependencies?: Record<string, string>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Dependencies.
|
|
95
|
+
*/
|
|
96
|
+
dependencies?: Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const configuration: Configuration = configurationJSON;
|
|
100
|
+
export const secureConfiguration: SecureConfiguration = secureConfigurationJSON;
|
|
101
|
+
|
|
102
|
+
const atOrganization = `@${configuration.organization}`;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Get the organization repository name or a dependency if it belongs to the organization or null if not.
|
|
106
|
+
*
|
|
107
|
+
* @param dependency
|
|
108
|
+
* Dependency.
|
|
109
|
+
*
|
|
110
|
+
* @returns
|
|
111
|
+
* Organization repository name or null.
|
|
112
|
+
*/
|
|
113
|
+
export function organizationRepository(dependency: string): string | null {
|
|
114
|
+
const [dependencyAtOrganization, dependencyRepositoryName] = dependency.split("/");
|
|
115
|
+
|
|
116
|
+
return dependencyAtOrganization === atOrganization ? dependencyRepositoryName : null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Determine if there have been any changes to a repository.
|
|
121
|
+
*
|
|
122
|
+
* @param repository
|
|
123
|
+
* Repository configuration.
|
|
124
|
+
*
|
|
125
|
+
* @param external
|
|
126
|
+
* False if comparing to the last internal published date/time, true if comparing to the last external published
|
|
127
|
+
* date/time.
|
|
128
|
+
*
|
|
129
|
+
* @returns
|
|
130
|
+
* True if there is no last published date/time or if there have been any changes since then.
|
|
131
|
+
*/
|
|
132
|
+
export function anyChanges(repository: Repository, external: boolean): boolean {
|
|
133
|
+
let anyChanges: boolean;
|
|
134
|
+
|
|
135
|
+
const lastPublishedString = !external ? repository.lastInternalPublished : repository.lastExternalPublished;
|
|
136
|
+
|
|
137
|
+
const excludedFilesSet = new Set(repository.excludeFiles ?? []);
|
|
138
|
+
|
|
139
|
+
const changedFilesSet = new Set<string>();
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Process a changed file.
|
|
143
|
+
*
|
|
144
|
+
* @param status
|
|
145
|
+
* "R" if the file has been renamed, "D" if the file has been deleted, otherwise file has been added.
|
|
146
|
+
*
|
|
147
|
+
* @param file
|
|
148
|
+
* Original file name if status is "R", otherwise file to be added or deleted.
|
|
149
|
+
*
|
|
150
|
+
* @param newFile
|
|
151
|
+
* New file name if status is "R", undefined otherwise.
|
|
152
|
+
*/
|
|
153
|
+
function processChangedFile(status: string, file: string, newFile: string | undefined): void {
|
|
154
|
+
// Status is "D" if deleted, "R" if renamed.
|
|
155
|
+
const deleteFile = status === "D" || status === "R" ? file : undefined;
|
|
156
|
+
const addFile = status === "R" ? newFile : status !== "D" ? file : undefined;
|
|
157
|
+
|
|
158
|
+
// Remove deleted file; anything that depends on a deleted file will have been modified.
|
|
159
|
+
if (deleteFile !== undefined && changedFilesSet.delete(deleteFile)) {
|
|
160
|
+
logger.debug(`-${deleteFile}`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (addFile !== undefined && !changedFilesSet.has(addFile)) {
|
|
164
|
+
// Exclude hidden files and directories except .github directory, as well as test directory and any explicitly excluded files.
|
|
165
|
+
if (((!addFile.startsWith(".") && !addFile.includes("/.")) || addFile.startsWith(".github/")) && !addFile.startsWith("test/") && !excludedFilesSet.has(addFile)) {
|
|
166
|
+
changedFilesSet.add(addFile);
|
|
167
|
+
|
|
168
|
+
logger.debug(`+${addFile}`);
|
|
169
|
+
} else {
|
|
170
|
+
// File is excluded.
|
|
171
|
+
logger.debug(`*${addFile}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (lastPublishedString !== undefined) {
|
|
177
|
+
for (const line of run(true, "git", "log", "--since", lastPublishedString, "--name-status", "--pretty=oneline")) {
|
|
178
|
+
// Header starts with 40-character SHA.
|
|
179
|
+
if (/^[0-9a-f]{40} /.test(line)) {
|
|
180
|
+
logger.debug(`Commit SHA ${line.substring(0, 40)}`);
|
|
181
|
+
} else {
|
|
182
|
+
const [status, file, newFile] = line.split("\t");
|
|
183
|
+
|
|
184
|
+
processChangedFile(status.charAt(0), file, newFile);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (lastPublishedString !== undefined || external) {
|
|
190
|
+
const output = run(true, "git", "status", "--porcelain");
|
|
191
|
+
|
|
192
|
+
if (output.length !== 0) {
|
|
193
|
+
// External publication requires that repository be fully committed.
|
|
194
|
+
// if (external) {
|
|
195
|
+
// throw new Error("Repository has uncommitted changes");
|
|
196
|
+
// }
|
|
197
|
+
|
|
198
|
+
logger.debug("Uncommitted");
|
|
199
|
+
|
|
200
|
+
for (const line of output) {
|
|
201
|
+
// Line is two-character status, space, and detail.
|
|
202
|
+
const status = line.substring(0, 1);
|
|
203
|
+
const [file, newFile] = line.substring(3).split(" -> ");
|
|
204
|
+
|
|
205
|
+
processChangedFile(status, file, newFile);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (lastPublishedString !== undefined) {
|
|
211
|
+
const lastPublished = new Date(lastPublishedString);
|
|
212
|
+
|
|
213
|
+
anyChanges = false;
|
|
214
|
+
|
|
215
|
+
for (const changedFile of changedFilesSet) {
|
|
216
|
+
if (fs.lstatSync(changedFile).mtime > lastPublished) {
|
|
217
|
+
if (!anyChanges) {
|
|
218
|
+
anyChanges = true;
|
|
219
|
+
|
|
220
|
+
logger.info("Changes");
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
logger.info(`>${changedFile}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (!anyChanges) {
|
|
228
|
+
logger.info("No changes");
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
// No last published, so there must have been changes.
|
|
232
|
+
anyChanges = true;
|
|
233
|
+
|
|
234
|
+
logger.info("No last published");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return anyChanges;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const configurationPath = "config/publish.json";
|
|
241
|
+
|
|
242
|
+
// Configuration may be written from any directory so full path is required.
|
|
243
|
+
const configurationFullPath = path.resolve(configurationPath);
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Save the current configuration.
|
|
247
|
+
*/
|
|
248
|
+
export function saveConfiguration(): void {
|
|
249
|
+
fs.writeFileSync(configurationFullPath, `${JSON.stringify(configuration, null, 2)}\n`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Publish all repositories.
|
|
254
|
+
*
|
|
255
|
+
* @param callback
|
|
256
|
+
* Callback taking the name and properties of the repository to publish.
|
|
257
|
+
*/
|
|
258
|
+
export async function publishRepositories(callback: (name: string, repository: Repository) => void | Promise<void>): Promise<void> {
|
|
259
|
+
const startDirectory = process.cwd();
|
|
260
|
+
|
|
261
|
+
for (const [name, repository] of Object.entries(configuration.repositories)) {
|
|
262
|
+
logger.info(`Repository ${name}...`);
|
|
263
|
+
|
|
264
|
+
// All repositories are expected to be children of the parent of this repository.
|
|
265
|
+
process.chdir(`../${repository.directory ?? name}`);
|
|
266
|
+
|
|
267
|
+
await callback(name, repository);
|
|
268
|
+
|
|
269
|
+
saveConfiguration();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Return to the start directory.
|
|
273
|
+
process.chdir(startDirectory);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Commit the current configuration.
|
|
278
|
+
*
|
|
279
|
+
* @param external
|
|
280
|
+
* False if committing due to internal publication, true if committing due to external publication.
|
|
281
|
+
*/
|
|
282
|
+
export function commitConfiguration(external: boolean): void {
|
|
283
|
+
// Check for changes before committing.
|
|
284
|
+
if (run(true, "git", "status", configurationPath, "--porcelain").length !== 0) {
|
|
285
|
+
run(false, "git", "commit", configurationPath, "--message", !external ? "Published internally." : "Published externally.");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -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.trace(`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,12 @@ 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
|
+
// Last line is also terminated by newline and split() places empty string at the end, so use slice() to remove it.
|
|
53
|
+
const output = captureOutput ? spawnResult.stdout.toString().split("\n").slice(0, -1) : [];
|
|
54
|
+
|
|
55
|
+
if (captureOutput) {
|
|
56
|
+
logger.trace(`Output is ${JSON.stringify(output)}.`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return output;
|
|
36
60
|
}
|
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
|
-
}
|