@git.zone/cli 8.2.1 → 8.2.3
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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/gitzone.cli.js +8 -2
- package/dist_ts/gitzone.logging.js +2 -2
- package/dist_ts/mod_commit/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_commit/mod.plugins.js +2 -3
- package/dist_ts/mod_deprecate/helpers.deprecation.d.ts +1 -1
- package/dist_ts/mod_deprecate/helpers.deprecation.js +32 -9
- package/dist_ts/mod_format/formatters/assets.formatter.js +3 -2
- package/dist_ts/mod_format/formatters/license.formatter.js +5 -3
- package/dist_ts/mod_format/formatters/templates.formatter.d.ts +1 -1
- package/dist_ts/mod_format/formatters/templates.formatter.js +4 -3
- package/dist_ts/mod_format/helpers.licensecheck.d.ts +12 -0
- package/dist_ts/mod_format/helpers.licensecheck.js +17 -0
- package/dist_ts/mod_format/mod.plugins.d.ts +1 -3
- package/dist_ts/mod_format/mod.plugins.js +2 -4
- package/dist_ts/mod_release/helpers.commitinfo.d.ts +20 -0
- package/dist_ts/mod_release/helpers.commitinfo.js +81 -0
- package/dist_ts/mod_release/helpers.npmartifact.d.ts +2 -0
- package/dist_ts/mod_release/helpers.npmartifact.js +4 -3
- package/dist_ts/mod_release/index.js +3 -5
- package/dist_ts/mod_release/mod.plugins.d.ts +0 -2
- package/dist_ts/mod_release/mod.plugins.js +1 -3
- package/dist_ts/mod_services/classes.dockercontainer.js +3 -3
- package/dist_ts/mod_services/classes.interprocesslock.js +2 -2
- package/dist_ts/mod_services/classes.legacymongomigration.js +2 -2
- package/dist_ts/mod_services/classes.servicemanager.js +2 -2
- package/dist_ts/mod_services/index.js +5 -5
- package/dist_ts/mod_services/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_services/mod.plugins.js +2 -3
- package/dist_ts/mod_template/classes.scaftemplate.d.ts +44 -0
- package/dist_ts/mod_template/classes.scaftemplate.js +115 -0
- package/dist_ts/mod_template/index.d.ts +2 -2
- package/dist_ts/mod_template/index.js +3 -2
- package/dist_ts/mod_template/mod.plugins.d.ts +6 -2
- package/dist_ts/mod_template/mod.plugins.js +7 -3
- package/dist_ts/plugins.d.ts +1 -2
- package/dist_ts/plugins.js +2 -3
- package/package.json +7 -8
- package/readme.md +8 -4
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/gitzone.cli.ts +8 -5
- package/ts/gitzone.logging.ts +1 -1
- package/ts/mod_commit/mod.plugins.ts +1 -2
- package/ts/mod_deprecate/helpers.deprecation.ts +63 -15
- package/ts/mod_format/formatters/assets.formatter.ts +2 -1
- package/ts/mod_format/formatters/license.formatter.ts +11 -6
- package/ts/mod_format/formatters/templates.formatter.ts +3 -2
- package/ts/mod_format/helpers.licensecheck.ts +40 -0
- package/ts/mod_format/mod.plugins.ts +0 -4
- package/ts/mod_release/helpers.commitinfo.ts +108 -0
- package/ts/mod_release/helpers.npmartifact.ts +3 -2
- package/ts/mod_release/index.ts +2 -4
- package/ts/mod_release/mod.plugins.ts +0 -4
- package/ts/mod_services/classes.dockercontainer.ts +2 -2
- package/ts/mod_services/classes.interprocesslock.ts +1 -1
- package/ts/mod_services/classes.legacymongomigration.ts +1 -1
- package/ts/mod_services/classes.servicemanager.ts +1 -1
- package/ts/mod_services/index.ts +4 -4
- package/ts/mod_services/mod.plugins.ts +1 -2
- package/ts/mod_template/classes.scaftemplate.ts +159 -0
- package/ts/mod_template/index.ts +2 -1
- package/ts/mod_template/mod.plugins.ts +7 -2
- package/ts/plugins.ts +0 -2
package/ts/gitzone.cli.ts
CHANGED
|
@@ -117,11 +117,14 @@ export let run = async () => {
|
|
|
117
117
|
if (rawCliMode.checkUpdates) {
|
|
118
118
|
const smartupdateInstance = new plugins.smartupdate.SmartUpdate();
|
|
119
119
|
try {
|
|
120
|
-
await smartupdateInstance.
|
|
121
|
-
|
|
122
|
-
packageVersion,
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
await smartupdateInstance.checkForUpdate({
|
|
121
|
+
packageName: commitinfo.name,
|
|
122
|
+
currentVersion: packageVersion,
|
|
123
|
+
changelogUrl:
|
|
124
|
+
"https://code.foss.global/api/v1/repos/git.zone/cli/raw/changelog.md",
|
|
125
|
+
openChangelog: false,
|
|
126
|
+
cacheStrategy: "never",
|
|
127
|
+
});
|
|
125
128
|
} catch {
|
|
126
129
|
// Update checks must never block actual CLI commands.
|
|
127
130
|
}
|
package/ts/gitzone.logging.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export * from "../plugins.js";
|
|
2
2
|
|
|
3
|
-
import * as commitinfo from "@push.rocks/commitinfo";
|
|
4
3
|
import * as smartfile from "@push.rocks/smartfile";
|
|
5
4
|
import * as smartshell from "@push.rocks/smartshell";
|
|
6
5
|
|
|
7
6
|
// Manual commits must not load or initialize the AI dependency chain.
|
|
8
7
|
export const loadTsdoc = () => import("@git.zone/tsdoc");
|
|
9
8
|
|
|
10
|
-
export {
|
|
9
|
+
export { smartfile, smartshell };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as plugins from "./mod.plugins.js";
|
|
2
|
-
import {
|
|
2
|
+
import { logger } from "../gitzone.logging.js";
|
|
3
|
+
import {
|
|
4
|
+
normalizeNpmRegistryUrl,
|
|
5
|
+
planNpmAvailabilityProbes,
|
|
6
|
+
probeDelayForAttempt,
|
|
7
|
+
} from "../mod_release/helpers.npmartifact.js";
|
|
3
8
|
|
|
4
9
|
export interface IDeprecationPlan {
|
|
5
10
|
packageName: string;
|
|
@@ -82,15 +87,16 @@ const readMetadata = async (
|
|
|
82
87
|
packageName: string,
|
|
83
88
|
fetchImplementation: typeof fetch,
|
|
84
89
|
): Promise<IPackageMetadata> => {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
const url = new URL(`${registry}/${encodeURIComponent(packageName)}`);
|
|
91
|
+
// CDNs such as the one in front of npmjs key cached metadata by URL and
|
|
92
|
+
// ignore no-cache request headers; a unique query reaches the origin.
|
|
93
|
+
url.searchParams.set("cache-bust", plugins.crypto.randomUUID());
|
|
94
|
+
const response = await fetchImplementation(url, {
|
|
95
|
+
method: "GET",
|
|
96
|
+
redirect: "error",
|
|
97
|
+
signal: AbortSignal.timeout(30_000),
|
|
98
|
+
headers: { accept: "application/json", "cache-control": "no-cache" },
|
|
99
|
+
});
|
|
94
100
|
if (response.status === 404)
|
|
95
101
|
throw new Error(`${packageName} is not published on ${registry}.`);
|
|
96
102
|
if (!response.ok)
|
|
@@ -125,6 +131,15 @@ const isDeprecationComplete = (
|
|
|
125
131
|
(version) => version.deprecated === message,
|
|
126
132
|
);
|
|
127
133
|
|
|
134
|
+
/**
|
|
135
|
+
* npmjs serves an accepted deprecation only after replication, which can take
|
|
136
|
+
* tens of seconds. Verification backs off from two seconds to twenty across a
|
|
137
|
+
* ninety-second window before it reports the registry as not yet verified.
|
|
138
|
+
*/
|
|
139
|
+
const deprecationVerificationWindowMs = 90_000;
|
|
140
|
+
const deprecationVerificationDelayMs = 2_000;
|
|
141
|
+
const deprecationVerificationMaxDelayMs = 20_000;
|
|
142
|
+
|
|
128
143
|
/**
|
|
129
144
|
* Verify the old package (and its replacement, when one is named) on every
|
|
130
145
|
* registry before changing metadata for any of them.
|
|
@@ -134,8 +149,15 @@ export const executeDeprecation = async (
|
|
|
134
149
|
shell: plugins.smartshell.Smartshell,
|
|
135
150
|
cwd: string,
|
|
136
151
|
fetchImplementation: typeof fetch = fetch,
|
|
152
|
+
delayImplementation: (millisecondsArg: number) => Promise<unknown> =
|
|
153
|
+
plugins.smartpromise.delayFor,
|
|
137
154
|
): Promise<void> => {
|
|
138
155
|
const plan = createDeprecationPlan(planArg);
|
|
156
|
+
const verification = planNpmAvailabilityProbes(
|
|
157
|
+
deprecationVerificationWindowMs,
|
|
158
|
+
deprecationVerificationDelayMs,
|
|
159
|
+
deprecationVerificationMaxDelayMs,
|
|
160
|
+
);
|
|
139
161
|
for (const registry of plan.registries) {
|
|
140
162
|
if (plan.replacement !== null) {
|
|
141
163
|
const replacement = await readMetadata(
|
|
@@ -163,7 +185,14 @@ export const executeDeprecation = async (
|
|
|
163
185
|
plan.packageName,
|
|
164
186
|
fetchImplementation,
|
|
165
187
|
);
|
|
166
|
-
if (isDeprecationComplete(existing, plan.message))
|
|
188
|
+
if (isDeprecationComplete(existing, plan.message)) {
|
|
189
|
+
logger.log(
|
|
190
|
+
"info",
|
|
191
|
+
`${plan.packageName} already carries this deprecation on ${registry}.`,
|
|
192
|
+
);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
logger.log("info", `Deprecating ${plan.packageName} on ${registry}.`);
|
|
167
196
|
const result = await shell.execSpawn(
|
|
168
197
|
"pnpm",
|
|
169
198
|
[
|
|
@@ -179,8 +208,13 @@ export const executeDeprecation = async (
|
|
|
179
208
|
timeoutKillGraceMs: 5_000,
|
|
180
209
|
},
|
|
181
210
|
);
|
|
211
|
+
if (result.exitCode !== 0)
|
|
212
|
+
logger.log(
|
|
213
|
+
"warn",
|
|
214
|
+
`pnpm deprecate exited with code ${result.exitCode} on ${registry}; checking whether the registry accepted the deprecation.`,
|
|
215
|
+
);
|
|
182
216
|
let verified = false;
|
|
183
|
-
for (let attempt = 0; attempt <
|
|
217
|
+
for (let attempt = 0; attempt < verification.attempts; attempt++) {
|
|
184
218
|
const metadata = await readMetadata(
|
|
185
219
|
registry,
|
|
186
220
|
plan.packageName,
|
|
@@ -190,15 +224,29 @@ export const executeDeprecation = async (
|
|
|
190
224
|
verified = true;
|
|
191
225
|
break;
|
|
192
226
|
}
|
|
193
|
-
if (attempt <
|
|
194
|
-
|
|
227
|
+
if (attempt + 1 < verification.attempts) {
|
|
228
|
+
const delayMs = probeDelayForAttempt(
|
|
229
|
+
attempt,
|
|
230
|
+
verification.delayMs,
|
|
231
|
+
verification.maxDelayMs,
|
|
232
|
+
);
|
|
233
|
+
logger.log(
|
|
234
|
+
"info",
|
|
235
|
+
`Deprecation is not yet visible for every version on ${registry}; checking again in ${delayMs / 1_000} s.`,
|
|
236
|
+
);
|
|
237
|
+
await delayImplementation(delayMs);
|
|
238
|
+
}
|
|
195
239
|
}
|
|
196
240
|
if (!verified) {
|
|
197
241
|
if (result.exitCode !== 0)
|
|
198
242
|
throw new Error(`Deprecation failed on ${registry}.`);
|
|
199
243
|
throw new Error(
|
|
200
|
-
`Deprecation is not yet verified for every version on ${registry}; rerunning the same deprecation is safe.`,
|
|
244
|
+
`Deprecation is not yet verified for every version on ${registry} after ${deprecationVerificationWindowMs / 1_000} s; rerunning the same deprecation is safe.`,
|
|
201
245
|
);
|
|
202
246
|
}
|
|
247
|
+
logger.log(
|
|
248
|
+
"ok",
|
|
249
|
+
`Verified the deprecation of every ${plan.packageName} version on ${registry}.`,
|
|
250
|
+
);
|
|
203
251
|
}
|
|
204
252
|
};
|
|
@@ -2,6 +2,7 @@ import { BaseFormatter } from '../classes.baseformatter.js';
|
|
|
2
2
|
import type { IFormatWarning, IPlannedChange } from '../interfaces.format.js';
|
|
3
3
|
import * as plugins from '../mod.plugins.js';
|
|
4
4
|
import * as paths from '../../paths.js';
|
|
5
|
+
import { ScafTemplate } from '../../mod_template/classes.scaftemplate.js';
|
|
5
6
|
import { logger, logVerbose } from '../../gitzone.logging.js';
|
|
6
7
|
import { getCliConfigValue, readSmartconfigFile } from '../../helpers.smartconfig.js';
|
|
7
8
|
import { getSealedReleaseConfigError } from '../../helpers.sealedrelease.js';
|
|
@@ -309,7 +310,7 @@ export class AssetsFormatter extends BaseFormatter {
|
|
|
309
310
|
throw new Error(`Managed asset template does not exist: ${templateName}`);
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
const scafTemplate = new
|
|
313
|
+
const scafTemplate = new ScafTemplate(templateDir);
|
|
313
314
|
await scafTemplate.readTemplateFromDir();
|
|
314
315
|
await scafTemplate.supplyVariables(variables);
|
|
315
316
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BaseFormatter } from '../classes.baseformatter.js';
|
|
2
2
|
import type { IFormatWarning, IPlannedChange } from '../interfaces.format.js';
|
|
3
3
|
import * as plugins from '../mod.plugins.js';
|
|
4
|
+
import {
|
|
5
|
+
findDependenciesWithLicenses,
|
|
6
|
+
type IPnpmLicensedPackage,
|
|
7
|
+
} from '../helpers.licensecheck.js';
|
|
4
8
|
import * as paths from '../../paths.js';
|
|
5
9
|
import { logger } from '../../gitzone.logging.js';
|
|
6
10
|
|
|
@@ -70,7 +74,7 @@ export class LicenseFormatter extends BaseFormatter {
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
private async checkLicenses(): Promise<{
|
|
73
|
-
failingModules:
|
|
77
|
+
failingModules: IPnpmLicensedPackage[];
|
|
74
78
|
} | undefined> {
|
|
75
79
|
const nodeModulesPath = plugins.path.join(paths.cwd, 'node_modules');
|
|
76
80
|
const nodeModulesExists = await plugins.smartfs
|
|
@@ -81,10 +85,11 @@ export class LicenseFormatter extends BaseFormatter {
|
|
|
81
85
|
return undefined;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
return {
|
|
89
|
+
failingModules: await findDependenciesWithLicenses(
|
|
90
|
+
paths.cwd,
|
|
91
|
+
INCOMPATIBLE_LICENSES,
|
|
92
|
+
),
|
|
93
|
+
};
|
|
89
94
|
}
|
|
90
95
|
}
|
|
@@ -2,6 +2,7 @@ import { BaseFormatter } from '../classes.baseformatter.js';
|
|
|
2
2
|
import type { IFormatWarning, IPlannedChange } from '../interfaces.format.js';
|
|
3
3
|
import * as plugins from '../mod.plugins.js';
|
|
4
4
|
import * as paths from '../../paths.js';
|
|
5
|
+
import { ScafTemplate } from '../../mod_template/classes.scaftemplate.js';
|
|
5
6
|
import { logger, logVerbose } from '../../gitzone.logging.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -43,12 +44,12 @@ export class TemplatesFormatter extends BaseFormatter {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
|
-
* Render a template directory
|
|
47
|
+
* Render a template directory and return a map of path → content.
|
|
47
48
|
*/
|
|
48
49
|
private async renderTemplate(templateName: string): Promise<Map<string, string>> {
|
|
49
50
|
const templateDir = plugins.path.join(paths.templatesDir, templateName);
|
|
50
51
|
|
|
51
|
-
const scafTemplate = new
|
|
52
|
+
const scafTemplate = new ScafTemplate(templateDir);
|
|
52
53
|
await scafTemplate.readTemplateFromDir();
|
|
53
54
|
|
|
54
55
|
const gitzoneData = this.project.gitzoneConfig?.data;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as plugins from './mod.plugins.js';
|
|
2
|
+
|
|
3
|
+
/** One license group entry of `pnpm licenses list --json`. */
|
|
4
|
+
export interface IPnpmLicensedPackage {
|
|
5
|
+
name: string;
|
|
6
|
+
versions: string[];
|
|
7
|
+
license: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** `pnpm licenses list --json` groups the installed packages by their license expression. */
|
|
11
|
+
export type TPnpmLicenseMap = Record<string, IPnpmLicensedPackage[]>;
|
|
12
|
+
|
|
13
|
+
/** Lists every installed dependency of the project with its license, as pnpm reports it. */
|
|
14
|
+
export const listDependencyLicenses = async (
|
|
15
|
+
projectDirArg: string,
|
|
16
|
+
): Promise<IPnpmLicensedPackage[]> => {
|
|
17
|
+
const smartshellInstance = new plugins.smartshell.Smartshell({ executor: 'bash' });
|
|
18
|
+
const result = await smartshellInstance.execSpawn('pnpm', ['licenses', 'list', '--json'], {
|
|
19
|
+
cwd: projectDirArg,
|
|
20
|
+
silent: true,
|
|
21
|
+
});
|
|
22
|
+
if (result.exitCode !== 0) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`\`pnpm licenses list --json\` exited with code ${result.exitCode} in ${projectDirArg}: ${
|
|
25
|
+
result.stdout.trim() || result.stderr.trim()
|
|
26
|
+
}`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
const licenseMap = JSON.parse(result.stdout) as TPnpmLicenseMap;
|
|
30
|
+
return Object.values(licenseMap).flat();
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** The dependencies whose license expression is exactly one of the given licenses. */
|
|
34
|
+
export const findDependenciesWithLicenses = async (
|
|
35
|
+
projectDirArg: string,
|
|
36
|
+
licensesArg: readonly string[],
|
|
37
|
+
): Promise<IPnpmLicensedPackage[]> =>
|
|
38
|
+
(await listDependencyLicenses(projectDirArg)).filter((packageArg) =>
|
|
39
|
+
licensesArg.includes(packageArg.license),
|
|
40
|
+
);
|
|
@@ -2,18 +2,14 @@ export * from '../plugins.js';
|
|
|
2
2
|
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import * as smartfile from '@push.rocks/smartfile';
|
|
5
|
-
import * as smartlegal from '@push.rocks/smartlegal';
|
|
6
5
|
import * as smartobject from '@push.rocks/smartobject';
|
|
7
6
|
import * as smartconfig from '@push.rocks/smartconfig';
|
|
8
7
|
import * as smartdiff from '@push.rocks/smartdiff';
|
|
9
|
-
import * as smartscaf from '@push.rocks/smartscaf';
|
|
10
8
|
|
|
11
9
|
export {
|
|
12
10
|
path,
|
|
13
11
|
smartfile,
|
|
14
|
-
smartlegal,
|
|
15
12
|
smartobject,
|
|
16
13
|
smartconfig,
|
|
17
14
|
smartdiff,
|
|
18
|
-
smartscaf,
|
|
19
15
|
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as plugins from "./mod.plugins.js";
|
|
2
|
+
|
|
3
|
+
/** The source folders that carry a baked commit info module, where they exist. */
|
|
4
|
+
export const commitInfoDirs = ["ts", "ts_web"] as const;
|
|
5
|
+
export const commitInfoFileName = "00_commitinfo_data.ts";
|
|
6
|
+
|
|
7
|
+
export interface ICommitInfo {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The escapes with a shorter spelling than `\uXXXX`, matching `JSON.stringify`. */
|
|
14
|
+
const stringLiteralEscapes: ReadonlyMap<string, string> = new Map([
|
|
15
|
+
["\\", "\\\\"],
|
|
16
|
+
["'", "\\'"],
|
|
17
|
+
["\b", "\\b"],
|
|
18
|
+
["\t", "\\t"],
|
|
19
|
+
["\n", "\\n"],
|
|
20
|
+
["\f", "\\f"],
|
|
21
|
+
["\r", "\\r"],
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The characters that may not stand as themselves inside a single-quoted
|
|
26
|
+
* TypeScript string: the backslash, the quote itself, the C0 control range,
|
|
27
|
+
* the line separators U+2028 and U+2029, and unpaired surrogates, which a
|
|
28
|
+
* utf8 write would otherwise turn into U+FFFD. Paired surrogates stay, so
|
|
29
|
+
* emoji remain readable in the generated file.
|
|
30
|
+
*/
|
|
31
|
+
const stringLiteralEscapePattern =
|
|
32
|
+
/['\\\u0000-\u001f\u2028\u2029]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/g;
|
|
33
|
+
|
|
34
|
+
/** Renders a value as a single-quoted TypeScript string literal that evaluates back to it. */
|
|
35
|
+
const toStringLiteral = (valueArg: string): string =>
|
|
36
|
+
`'${valueArg.replace(
|
|
37
|
+
stringLiteralEscapePattern,
|
|
38
|
+
(characterArg) =>
|
|
39
|
+
stringLiteralEscapes.get(characterArg) ??
|
|
40
|
+
`\\u${characterArg.charCodeAt(0).toString(16).padStart(4, "0")}`,
|
|
41
|
+
)}'`;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The baked module. Every project commits it, so its bytes are a contract:
|
|
45
|
+
* the header, the key order, single-quoted literals, two-space indentation
|
|
46
|
+
* and the trailing newline stay exactly as `@push.rocks/commitinfo` wrote them.
|
|
47
|
+
*/
|
|
48
|
+
export const renderCommitInfoModule = (infoArg: ICommitInfo): string =>
|
|
49
|
+
`/**
|
|
50
|
+
* autocreated commitinfo by @push.rocks/commitinfo
|
|
51
|
+
*/
|
|
52
|
+
export const commitinfo = {
|
|
53
|
+
name: ${toStringLiteral(infoArg.name)},
|
|
54
|
+
version: ${toStringLiteral(infoArg.version)},
|
|
55
|
+
description: ${toStringLiteral(infoArg.description)}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const isDirectory = async (pathArg: string): Promise<boolean> => {
|
|
60
|
+
try {
|
|
61
|
+
return (await plugins.fs.stat(pathArg)).isDirectory();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Bakes the package name and description from package.json together with the
|
|
72
|
+
* release version into `00_commitinfo_data.ts` of every commit info folder the
|
|
73
|
+
* project has. Returns the written files.
|
|
74
|
+
*/
|
|
75
|
+
export const writeCommitInfoFiles = async (
|
|
76
|
+
projectDirArg: string,
|
|
77
|
+
versionArg: string,
|
|
78
|
+
): Promise<string[]> => {
|
|
79
|
+
const targetDirs: string[] = [];
|
|
80
|
+
for (const dir of commitInfoDirs) {
|
|
81
|
+
const dirPath = plugins.path.join(projectDirArg, dir);
|
|
82
|
+
if (await isDirectory(dirPath)) {
|
|
83
|
+
targetDirs.push(dirPath);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (targetDirs.length === 0) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const packageJson = JSON.parse(
|
|
90
|
+
await plugins.fs.readFile(
|
|
91
|
+
plugins.path.join(projectDirArg, "package.json"),
|
|
92
|
+
"utf8",
|
|
93
|
+
),
|
|
94
|
+
) as { name?: unknown; description?: unknown };
|
|
95
|
+
const moduleSource = renderCommitInfoModule({
|
|
96
|
+
name: typeof packageJson.name === "string" ? packageJson.name : "",
|
|
97
|
+
version: versionArg,
|
|
98
|
+
description:
|
|
99
|
+
typeof packageJson.description === "string" ? packageJson.description : "",
|
|
100
|
+
});
|
|
101
|
+
const writtenFiles: string[] = [];
|
|
102
|
+
for (const dirPath of targetDirs) {
|
|
103
|
+
const filePath = plugins.path.join(dirPath, commitInfoFileName);
|
|
104
|
+
await plugins.fs.writeFile(filePath, moduleSource, "utf8");
|
|
105
|
+
writtenFiles.push(filePath);
|
|
106
|
+
}
|
|
107
|
+
return writtenFiles;
|
|
108
|
+
};
|
|
@@ -111,7 +111,8 @@ export interface INpmArtifactProbeOptions {
|
|
|
111
111
|
/** npmjs usually serves a new version within minutes; an hour has happened. */
|
|
112
112
|
export const defaultNpmVerificationWindowMinutes = 15;
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
/** The delay after the zero-based probe `attemptArg` under doubling backoff. */
|
|
115
|
+
export const probeDelayForAttempt = (
|
|
115
116
|
attemptArg: number,
|
|
116
117
|
delayMsArg: number,
|
|
117
118
|
maxDelayMsArg: number,
|
|
@@ -1136,7 +1137,7 @@ const waitForNpmProbe = async (
|
|
|
1136
1137
|
return lastResult;
|
|
1137
1138
|
}
|
|
1138
1139
|
if (attempt + 1 < attempts) {
|
|
1139
|
-
await plugins.
|
|
1140
|
+
await plugins.smartpromise.delayFor(
|
|
1140
1141
|
probeDelayForAttempt(attempt, delayMs, maxDelayMs),
|
|
1141
1142
|
);
|
|
1142
1143
|
}
|
package/ts/mod_release/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type IResolvedReleaseWorkflow,
|
|
19
19
|
} from "../helpers.workflow.js";
|
|
20
20
|
import * as commitHelpers from "../mod_commit/mod.helpers.js";
|
|
21
|
+
import { writeCommitInfoFiles } from "./helpers.commitinfo.js";
|
|
21
22
|
import {
|
|
22
23
|
inspectReleaseBranch,
|
|
23
24
|
integrateReleaseBranch,
|
|
@@ -1810,10 +1811,7 @@ async function runVersionStep(
|
|
|
1810
1811
|
`Bumping version: ${currentVersion} -> ${resolutionArg.version}`,
|
|
1811
1812
|
);
|
|
1812
1813
|
|
|
1813
|
-
|
|
1814
|
-
version: resolutionArg.version,
|
|
1815
|
-
});
|
|
1816
|
-
await commitInfo.writeIntoPotentialDirs();
|
|
1814
|
+
await writeCommitInfoFiles(cwdArg, resolutionArg.version);
|
|
1817
1815
|
await commitHelpers.updateProjectVersionFiles(
|
|
1818
1816
|
projectType,
|
|
1819
1817
|
resolutionArg.version,
|
|
@@ -591,7 +591,7 @@ export class DockerContainer {
|
|
|
591
591
|
/** Longer bound for root-helper cleanup, which may delete a large tree. */
|
|
592
592
|
private cleanupTimeoutSeconds = 600;
|
|
593
593
|
private bindOperationDelay = async (millisecondsArg: number): Promise<void> =>
|
|
594
|
-
plugins.
|
|
594
|
+
plugins.smartpromise.delayFor(millisecondsArg);
|
|
595
595
|
|
|
596
596
|
constructor() {
|
|
597
597
|
this.smartshell = new plugins.smartshell.Smartshell({
|
|
@@ -1624,7 +1624,7 @@ export class DockerContainer {
|
|
|
1624
1624
|
if (await this.isRunning(containerName)) {
|
|
1625
1625
|
return true;
|
|
1626
1626
|
}
|
|
1627
|
-
await plugins.
|
|
1627
|
+
await plugins.smartpromise.delayFor(1000);
|
|
1628
1628
|
}
|
|
1629
1629
|
return false;
|
|
1630
1630
|
}
|
|
@@ -118,7 +118,7 @@ export class InterProcessLock {
|
|
|
118
118
|
`If that process no longer exists, inspect and remove ${this.lockPath}.`,
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
|
-
await plugins.
|
|
121
|
+
await plugins.smartpromise.delayFor(Math.min(this.pollMs, remaining));
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -1115,7 +1115,7 @@ export class LegacyMongoMigration {
|
|
|
1115
1115
|
if (Date.now() > deadline) {
|
|
1116
1116
|
throw new Error(`The temporary MongoDB reader ${name} did not become ready in time.`);
|
|
1117
1117
|
}
|
|
1118
|
-
await plugins.
|
|
1118
|
+
await plugins.smartpromise.delayFor(readerPollIntervalMs);
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
@@ -216,7 +216,7 @@ export interface IObjectStorageBucketReconciliationOptions {
|
|
|
216
216
|
|
|
217
217
|
const defaultObjectStorageClock: IObjectStorageReconciliationClock = {
|
|
218
218
|
now: () => Date.now(),
|
|
219
|
-
delay: async (millisecondsArg) => plugins.
|
|
219
|
+
delay: async (millisecondsArg) => plugins.smartpromise.delayFor(millisecondsArg),
|
|
220
220
|
};
|
|
221
221
|
|
|
222
222
|
class ObjectStorageStageError extends Error {
|
package/ts/mod_services/index.ts
CHANGED
|
@@ -504,7 +504,7 @@ export async function handleRestart(serviceManager: ServiceManager, service: str
|
|
|
504
504
|
case "mongodb":
|
|
505
505
|
await serviceManager.assertMongoStartupAllowed();
|
|
506
506
|
await serviceManager.stopMongoDB();
|
|
507
|
-
await plugins.
|
|
507
|
+
await plugins.smartpromise.delayFor(2000);
|
|
508
508
|
await serviceManager.startMongoDB();
|
|
509
509
|
restarted = true;
|
|
510
510
|
break;
|
|
@@ -513,7 +513,7 @@ export async function handleRestart(serviceManager: ServiceManager, service: str
|
|
|
513
513
|
case "s3":
|
|
514
514
|
await serviceManager.assertObjectStorageStartupAllowed();
|
|
515
515
|
await serviceManager.stopObjectStorage();
|
|
516
|
-
await plugins.
|
|
516
|
+
await plugins.smartpromise.delayFor(2000);
|
|
517
517
|
await serviceManager.startObjectStorage();
|
|
518
518
|
restarted = true;
|
|
519
519
|
break;
|
|
@@ -521,7 +521,7 @@ export async function handleRestart(serviceManager: ServiceManager, service: str
|
|
|
521
521
|
case "elasticsearch":
|
|
522
522
|
case "es":
|
|
523
523
|
await serviceManager.stopElasticsearch();
|
|
524
|
-
await plugins.
|
|
524
|
+
await plugins.smartpromise.delayFor(2000);
|
|
525
525
|
await serviceManager.startElasticsearch();
|
|
526
526
|
restarted = true;
|
|
527
527
|
break;
|
|
@@ -535,7 +535,7 @@ export async function handleRestart(serviceManager: ServiceManager, service: str
|
|
|
535
535
|
await serviceManager.assertObjectStorageStartupAllowed();
|
|
536
536
|
}
|
|
537
537
|
await serviceManager.stopAll();
|
|
538
|
-
await plugins.
|
|
538
|
+
await plugins.smartpromise.delayFor(2000);
|
|
539
539
|
await serviceManager.startAll();
|
|
540
540
|
restarted = true;
|
|
541
541
|
break;
|
|
@@ -3,9 +3,8 @@ export * from '../plugins.js';
|
|
|
3
3
|
import * as smartshell from '@push.rocks/smartshell';
|
|
4
4
|
import * as smartfile from '@push.rocks/smartfile';
|
|
5
5
|
import * as smartnetwork from '@push.rocks/smartnetwork';
|
|
6
|
-
import * as smartdelay from '@push.rocks/smartdelay';
|
|
7
6
|
|
|
8
7
|
// @lossless.org scope
|
|
9
8
|
import * as nosqldb from '@lossless.org/client/nosqldb';
|
|
10
9
|
|
|
11
|
-
export { smartshell, smartfile, smartnetwork,
|
|
10
|
+
export { smartshell, smartfile, smartnetwork, nosqldb };
|