@git.zone/cli 8.2.2 → 8.3.0
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/helpers.ownerscopes.d.ts +19 -0
- package/dist_ts/helpers.ownerscopes.js +81 -0
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- 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.js +2 -2
- package/dist_ts/mod_format/formatters/assets.formatter.js +3 -2
- package/dist_ts/mod_format/formatters/deno.formatter.d.ts +18 -0
- package/dist_ts/mod_format/formatters/deno.formatter.js +175 -0
- 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/index.js +4 -1
- package/dist_ts/mod_format/interfaces.format.js +2 -1
- 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.js +2 -2
- 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 +6 -7
- package/readme.md +24 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.ownerscopes.ts +81 -0
- package/ts/index.ts +2 -0
- package/ts/mod_commit/mod.plugins.ts +1 -2
- package/ts/mod_deprecate/helpers.deprecation.ts +1 -1
- package/ts/mod_format/formatters/assets.formatter.ts +2 -1
- package/ts/mod_format/formatters/deno.formatter.ts +219 -0
- 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/index.ts +3 -0
- package/ts/mod_format/interfaces.format.ts +1 -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 +1 -1
- 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/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 };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as plugins from './mod.plugins.js';
|
|
2
|
+
import { answerDefaultsWithoutTerminal, withPrompts } from '../helpers.prompts.js';
|
|
3
|
+
|
|
4
|
+
/** The file at the root of a template folder that configures the template. */
|
|
5
|
+
export const scafConfigFileName = '.smartscaf.yml';
|
|
6
|
+
|
|
7
|
+
/** The content of a template's `.smartscaf.yml`. */
|
|
8
|
+
export interface IScafTemplateConfig {
|
|
9
|
+
/** The answers offered for missing variables, keyed by their dotted name. */
|
|
10
|
+
defaults: Record<string, unknown>;
|
|
11
|
+
/** Template folders, relative to this one, whose files are merged into it. */
|
|
12
|
+
dependencies: {
|
|
13
|
+
merge: string[];
|
|
14
|
+
};
|
|
15
|
+
/** Shell commands run in the destination after the template is written. */
|
|
16
|
+
runafter: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A handlebars template folder: every file is rendered with the supplied
|
|
21
|
+
* variables, a `fileName` frontmatter entry renames the rendered file, and
|
|
22
|
+
* `{-{ … }-}` survives rendering as `{{ … }}`.
|
|
23
|
+
*/
|
|
24
|
+
export class ScafTemplate {
|
|
25
|
+
public readonly dirPath: string;
|
|
26
|
+
public config: IScafTemplateConfig = {
|
|
27
|
+
defaults: {},
|
|
28
|
+
dependencies: { merge: [] },
|
|
29
|
+
runafter: [],
|
|
30
|
+
};
|
|
31
|
+
/** The template files, followed by the files of every merged template. */
|
|
32
|
+
public templateFiles: plugins.smartfile.SmartFile[] = [];
|
|
33
|
+
public suppliedVariables: Record<string, unknown> = {};
|
|
34
|
+
public missingVariables: string[] = [];
|
|
35
|
+
|
|
36
|
+
constructor(dirPathArg: string) {
|
|
37
|
+
this.dirPath = plugins.path.resolve(dirPathArg);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Reads the template folder, its configuration and the templates it merges. */
|
|
41
|
+
public async readTemplateFromDir(): Promise<void> {
|
|
42
|
+
const ownFiles = await readFolderFiles(this.dirPath);
|
|
43
|
+
const configFile = ownFiles.find((fileArg) => fileArg.path === scafConfigFileName);
|
|
44
|
+
const parsedConfig = configFile
|
|
45
|
+
? ((await plugins.smartyaml.yamlStringToObject(
|
|
46
|
+
configFile.contents.toString(),
|
|
47
|
+
)) as Partial<IScafTemplateConfig> | null)
|
|
48
|
+
: null;
|
|
49
|
+
this.config = {
|
|
50
|
+
defaults: parsedConfig?.defaults ?? {},
|
|
51
|
+
dependencies: { merge: parsedConfig?.dependencies?.merge ?? [] },
|
|
52
|
+
runafter: parsedConfig?.runafter ?? [],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
this.templateFiles = ownFiles;
|
|
56
|
+
for (const dependency of this.config.dependencies.merge) {
|
|
57
|
+
const dependencyDir = plugins.path.join(this.dirPath, dependency);
|
|
58
|
+
if (!(await plugins.smartfs.directory(dependencyDir).exists())) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Template ${this.dirPath} merges ${dependency}, which is not a folder at ${dependencyDir}`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
this.templateFiles.push(...(await readFolderFiles(dependencyDir)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Merges the given variables into the supplied ones and updates the missing variables. */
|
|
68
|
+
public async supplyVariables(variablesArg: Record<string, unknown>): Promise<void> {
|
|
69
|
+
this.suppliedVariables = {
|
|
70
|
+
...this.suppliedVariables,
|
|
71
|
+
...variablesArg,
|
|
72
|
+
};
|
|
73
|
+
this.missingVariables = await this.findMissingVariables();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Asks for every missing variable, offering the template default. Without an
|
|
78
|
+
* interactive terminal the defaults are taken.
|
|
79
|
+
*/
|
|
80
|
+
public async askCliForMissingVariables(): Promise<void> {
|
|
81
|
+
this.missingVariables = await this.findMissingVariables();
|
|
82
|
+
if (this.missingVariables.length === 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const questions: plugins.smartconsole.IInputQuestion[] = this.missingVariables.map(
|
|
86
|
+
(variableArg) => {
|
|
87
|
+
const defaultValue = this.config.defaults[variableArg];
|
|
88
|
+
return {
|
|
89
|
+
name: variableArg,
|
|
90
|
+
type: 'input',
|
|
91
|
+
default: defaultValue ? String(defaultValue) : 'undefined variable',
|
|
92
|
+
message: `What is the value of ${variableArg}?`,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
const answers = await withPrompts((promptsArg) =>
|
|
97
|
+
promptsArg.askAll(questions, answerDefaultsWithoutTerminal),
|
|
98
|
+
);
|
|
99
|
+
for (const [variable, value] of Object.entries(answers)) {
|
|
100
|
+
plugins.smartobject.smartAdd(this.suppliedVariables, variable, value);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Renders every template file in memory; the template files stay untouched. */
|
|
105
|
+
public async renderToMemory(): Promise<plugins.smartfile.SmartFile[]> {
|
|
106
|
+
const renderedFiles: plugins.smartfile.SmartFile[] = [];
|
|
107
|
+
for (const templateFile of this.getContentFiles()) {
|
|
108
|
+
const document = await plugins.smartmarkdown.parseFrontmatter(
|
|
109
|
+
plugins.smarthbs.renderString(templateFile.contents.toString(), this.suppliedVariables),
|
|
110
|
+
);
|
|
111
|
+
const fileName = document.data.fileName;
|
|
112
|
+
const filePath =
|
|
113
|
+
typeof fileName === 'string' && fileName
|
|
114
|
+
? plugins.path.join(plugins.path.dirname(templateFile.path), fileName)
|
|
115
|
+
: templateFile.path;
|
|
116
|
+
renderedFiles.push(
|
|
117
|
+
plugins.smartFileFactory.fromBuffer(
|
|
118
|
+
filePath,
|
|
119
|
+
Buffer.from(await plugins.smarthbs.postprocess(document.content)),
|
|
120
|
+
templateFile.base,
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return renderedFiles;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Renders the template into the destination folder and runs its `runafter` commands there. */
|
|
128
|
+
public async writeToDisk(destinationDirArg: string): Promise<void> {
|
|
129
|
+
const renderedFiles = await this.renderToMemory();
|
|
130
|
+
await plugins.smartFileFactory
|
|
131
|
+
.virtualDirectoryFromFileArray(renderedFiles)
|
|
132
|
+
.saveToDisk(destinationDirArg);
|
|
133
|
+
const smartshellInstance = new plugins.smartshell.Smartshell({ executor: 'bash' });
|
|
134
|
+
for (const command of this.config.runafter) {
|
|
135
|
+
await smartshellInstance.execStrict(command, { cwd: destinationDirArg });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The files that get rendered: everything except the configuration of each merged template. */
|
|
140
|
+
private getContentFiles(): plugins.smartfile.SmartFile[] {
|
|
141
|
+
return this.templateFiles.filter((fileArg) => fileArg.path !== scafConfigFileName);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private async findMissingVariables(): Promise<string[]> {
|
|
145
|
+
const missingVariables = new Set<string>();
|
|
146
|
+
for (const templateFile of this.getContentFiles()) {
|
|
147
|
+
for (const variable of await plugins.smarthbs.checkVarsSatisfaction(
|
|
148
|
+
templateFile.contents.toString(),
|
|
149
|
+
this.suppliedVariables,
|
|
150
|
+
)) {
|
|
151
|
+
missingVariables.add(variable);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return [...missingVariables];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const readFolderFiles = async (dirPathArg: string): Promise<plugins.smartfile.SmartFile[]> =>
|
|
159
|
+
(await plugins.smartFileFactory.virtualDirectoryFromPath(dirPathArg)).listFiles();
|
package/ts/mod_template/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as plugins from './mod.plugins.js';
|
|
2
2
|
import * as paths from '../paths.js';
|
|
3
|
+
import { ScafTemplate } from './classes.scaftemplate.js';
|
|
3
4
|
|
|
4
5
|
import { logger } from '../gitzone.logging.js';
|
|
5
6
|
import { answerDefaultsWithoutTerminal, ask, stringChoices } from '../helpers.prompts.js';
|
|
@@ -17,7 +18,7 @@ export const isTemplate = async (templateNameArg: string) => {
|
|
|
17
18
|
|
|
18
19
|
export const getTemplate = async (templateNameArg: string) => {
|
|
19
20
|
if (await isTemplate(templateNameArg)) {
|
|
20
|
-
const localScafTemplate = new
|
|
21
|
+
const localScafTemplate = new ScafTemplate(
|
|
21
22
|
getTemplatePath(templateNameArg),
|
|
22
23
|
);
|
|
23
24
|
await localScafTemplate.readTemplateFromDir();
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export * from '../plugins.js';
|
|
2
2
|
|
|
3
3
|
import * as smartfile from '@push.rocks/smartfile';
|
|
4
|
-
import * as
|
|
4
|
+
import * as smarthbs from '@push.rocks/smarthbs/iso';
|
|
5
|
+
import * as smartmarkdown from '@push.rocks/smartmarkdown/iso';
|
|
6
|
+
import * as smartobject from '@push.rocks/smartobject';
|
|
7
|
+
import * as smartyaml from '@push.rocks/smartyaml';
|
|
5
8
|
|
|
6
|
-
export
|
|
9
|
+
export const smartFileFactory = smartfile.SmartFileFactory.nodeFs();
|
|
10
|
+
|
|
11
|
+
export { smartfile, smarthbs, smartmarkdown, smartobject, smartyaml };
|
package/ts/plugins.ts
CHANGED
|
@@ -18,7 +18,6 @@ import * as smartshell from '@push.rocks/smartshell';
|
|
|
18
18
|
import * as smartnetwork from '@push.rocks/smartnetwork';
|
|
19
19
|
import * as smartfile from '@push.rocks/smartfile';
|
|
20
20
|
import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
|
|
21
|
-
import * as smartdelay from '@push.rocks/smartdelay';
|
|
22
21
|
|
|
23
22
|
// @lossless.org scope
|
|
24
23
|
import * as objectstorage from '@lossless.org/client/objectstorage';
|
|
@@ -68,7 +67,6 @@ export {
|
|
|
68
67
|
smartshell,
|
|
69
68
|
smartnetwork,
|
|
70
69
|
smartfile,
|
|
71
|
-
smartdelay,
|
|
72
70
|
objectstorage,
|
|
73
71
|
s3,
|
|
74
72
|
tsdockerReleaseProtocol,
|