@git.zone/cli 9.2.2 → 11.0.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/.smartconfig.json +5 -3
- package/assets/templates/asset_binary_installer/install.sh +109 -34
- package/assets/templates/asset_binary_release_gitea/.gitea/workflows/release.yml +17 -4
- package/assets/templates/ci_rust/.gitea/workflows/rust_nottags.yaml +29 -0
- package/assets/templates/ci_rust/.gitea/workflows/rust_tags.yaml +32 -0
- package/assets/templates/cli/cli.ts.js +1 -1
- package/assets/templates/gitignore/_gitignore +1 -1
- package/assets/templates/gitignore_rust/_gitignore +31 -0
- package/assets/templates/license_mit/license +4 -1
- package/assets/templates/npm/.package.json +4 -6
- package/assets/templates/npm/test/test.ts +1 -1
- package/assets/templates/rust/.smartscaf.yml +16 -0
- package/assets/templates/rust/_Cargo.toml +12 -0
- package/assets/templates/rust/_crate_Cargo.toml +10 -0
- package/assets/templates/rust/_crate_lib.rs +19 -0
- package/assets/templates/rust/_smartconfig.json +27 -0
- package/assets/templates/rust/readme.md +23 -0
- package/assets/templates/service/.package.json +3 -6
- package/assets/templates/wcc/.package.json +3 -6
- package/assets/templates/wcc_update/html/index.html +2 -2
- package/assets/templates/website/.package.json +3 -6
- package/assets/templates/website/npmextra.json +3 -1
- package/assets/templates/website_update/html/index.html +4 -4
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/classes.gitzoneconfig.d.ts +3 -1
- package/dist_ts/classes.gitzoneconfig.js +9 -1
- package/dist_ts/helpers.managedassets.d.ts +1 -1
- package/dist_ts/helpers.managedassets.js +58 -14
- package/dist_ts/helpers.packagefiles.js +2 -2
- package/dist_ts/helpers.releasetargets.d.ts +6 -0
- package/dist_ts/helpers.releasetargets.js +13 -0
- package/dist_ts/helpers.smartconfigmigrations.js +42 -1
- package/dist_ts/helpers.toolconfig.d.ts +50 -0
- package/dist_ts/helpers.toolconfig.js +212 -0
- package/dist_ts/helpers.tssea.d.ts +11 -4
- package/dist_ts/helpers.tssea.js +47 -17
- package/dist_ts/helpers.tstest.d.ts +27 -8
- package/dist_ts/helpers.tstest.js +64 -26
- package/dist_ts/helpers.versionsource.d.ts +37 -0
- package/dist_ts/helpers.versionsource.js +112 -0
- package/dist_ts/helpers.workflow.d.ts +45 -1
- package/dist_ts/helpers.workflow.js +120 -5
- package/dist_ts/mod_commit/mod.helpers.d.ts +0 -24
- package/dist_ts/mod_commit/mod.helpers.js +1 -94
- package/dist_ts/mod_commit/mod.plugins.d.ts +1 -1
- package/dist_ts/mod_commit/mod.plugins.js +2 -2
- package/dist_ts/mod_config/index.js +131 -18
- package/dist_ts/mod_format/formatters/assets.formatter.js +30 -28
- package/dist_ts/mod_format/formatters/gitignore.formatter.d.ts +4 -2
- package/dist_ts/mod_format/formatters/gitignore.formatter.js +10 -7
- package/dist_ts/mod_format/formatters/license.formatter.d.ts +8 -0
- package/dist_ts/mod_format/formatters/license.formatter.js +25 -2
- package/dist_ts/mod_format/formatters/packagejson.formatter.js +14 -3
- package/dist_ts/mod_format/formatters/rustfmt.formatter.d.ts +19 -0
- package/dist_ts/mod_format/formatters/rustfmt.formatter.js +97 -0
- package/dist_ts/mod_format/formatters/smartconfig.formatter.js +5 -2
- package/dist_ts/mod_format/formatters/templates.formatter.d.ts +3 -2
- package/dist_ts/mod_format/formatters/templates.formatter.js +61 -14
- package/dist_ts/mod_format/formatters/tsconfig.formatter.js +2 -2
- package/dist_ts/mod_format/index.js +3 -1
- package/dist_ts/mod_format/interfaces.format.js +2 -1
- package/dist_ts/mod_release/classes.releasejournal.d.ts +38 -2
- package/dist_ts/mod_release/classes.releasejournal.js +238 -66
- package/dist_ts/mod_release/helpers.cargorelease.d.ts +52 -0
- package/dist_ts/mod_release/helpers.cargorelease.js +195 -0
- package/dist_ts/mod_release/helpers.npmpackages.d.ts +18 -0
- package/dist_ts/mod_release/helpers.npmpackages.js +40 -2
- package/dist_ts/mod_release/helpers.releasecheck.d.ts +73 -0
- package/dist_ts/mod_release/helpers.releasecheck.js +269 -0
- package/dist_ts/mod_release/helpers.releasepreparation.d.ts +22 -8
- package/dist_ts/mod_release/helpers.releasepreparation.js +74 -26
- package/dist_ts/mod_release/helpers.releasepublication.d.ts +21 -1
- package/dist_ts/mod_release/helpers.releasepublication.js +249 -4
- package/dist_ts/mod_release/helpers.releaseversionsource.d.ts +10 -0
- package/dist_ts/mod_release/helpers.releaseversionsource.js +18 -0
- package/dist_ts/mod_release/helpers.rsrepoengine.d.ts +192 -0
- package/dist_ts/mod_release/helpers.rsrepoengine.js +457 -0
- package/dist_ts/mod_release/index.d.ts +3 -0
- package/dist_ts/mod_release/index.js +177 -65
- package/dist_ts/mod_template/index.js +6 -2
- package/dist_ts/mod_tools/index.js +3 -8
- package/dist_ts/plugins.d.ts +1 -1
- package/dist_ts/plugins.js +2 -2
- package/package.json +6 -11
- package/readme.md +244 -26
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.gitzoneconfig.ts +10 -1
- package/ts/helpers.managedassets.ts +64 -14
- package/ts/helpers.packagefiles.ts +1 -1
- package/ts/helpers.releasetargets.ts +13 -0
- package/ts/helpers.smartconfigmigrations.ts +48 -0
- package/ts/helpers.toolconfig.ts +280 -0
- package/ts/helpers.tssea.ts +62 -19
- package/ts/helpers.tstest.ts +105 -35
- package/ts/helpers.versionsource.ts +169 -0
- package/ts/helpers.workflow.ts +197 -5
- package/ts/mod_commit/mod.helpers.ts +0 -119
- package/ts/mod_commit/mod.plugins.ts +1 -1
- package/ts/mod_config/index.ts +169 -19
- package/ts/mod_format/formatters/assets.formatter.ts +29 -28
- package/ts/mod_format/formatters/gitignore.formatter.ts +10 -6
- package/ts/mod_format/formatters/license.formatter.ts +26 -1
- package/ts/mod_format/formatters/packagejson.formatter.ts +14 -2
- package/ts/mod_format/formatters/rustfmt.formatter.ts +107 -0
- package/ts/mod_format/formatters/smartconfig.formatter.ts +8 -1
- package/ts/mod_format/formatters/templates.formatter.ts +80 -14
- package/ts/mod_format/formatters/tsconfig.formatter.ts +1 -1
- package/ts/mod_format/index.ts +2 -0
- package/ts/mod_format/interfaces.format.ts +1 -0
- package/ts/mod_release/classes.releasejournal.ts +312 -39
- package/ts/mod_release/helpers.cargorelease.ts +289 -0
- package/ts/mod_release/helpers.npmpackages.ts +76 -1
- package/ts/mod_release/helpers.releasecheck.ts +409 -0
- package/ts/mod_release/helpers.releasepreparation.ts +116 -36
- package/ts/mod_release/helpers.releasepublication.ts +462 -1
- package/ts/mod_release/helpers.releaseversionsource.ts +29 -0
- package/ts/mod_release/helpers.rsrepoengine.ts +790 -0
- package/ts/mod_release/index.ts +277 -84
- package/ts/mod_template/index.ts +5 -1
- package/ts/mod_tools/index.ts +2 -7
- package/ts/plugins.ts +1 -1
|
@@ -70,7 +70,14 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
70
70
|
"module.description",
|
|
71
71
|
"module.npmPackagename",
|
|
72
72
|
"module.license",
|
|
73
|
-
]
|
|
73
|
+
].filter(
|
|
74
|
+
// A Rust repository publishes crates, never an npm package.
|
|
75
|
+
(fieldArg) =>
|
|
76
|
+
!(
|
|
77
|
+
fieldArg === "module.npmPackagename" &&
|
|
78
|
+
smartconfigJson["@git.zone/cli"].projectType === "rust"
|
|
79
|
+
),
|
|
80
|
+
);
|
|
74
81
|
|
|
75
82
|
const missingRepoInformation = expectedRepoInformation.filter(
|
|
76
83
|
(expectedRepoInformationItem) => {
|
|
@@ -32,32 +32,86 @@ interface IJsonObjectParseOutcome {
|
|
|
32
32
|
reason?: string;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The rendered files of a template, or why it cannot render: a variable the
|
|
37
|
+
* configuration does not supply would render as an empty string.
|
|
38
|
+
*/
|
|
39
|
+
type TTemplateRenderOutcome =
|
|
40
|
+
| { files: Map<string, string> }
|
|
41
|
+
| { unsatisfiedReasons: string[] };
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Module values the templates link as `https://<value>/…`: a host with an
|
|
45
|
+
* optional port and path, never a whole URL or a trailing slash.
|
|
46
|
+
*/
|
|
47
|
+
const templateHostKeys = ['assetbrokerUrl', 'legalUrl'];
|
|
48
|
+
const templateHostPattern = /^[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:\d{1,5})?(\/[^\s/?#]+)*$/i;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The module values the templates render with. A blank value, or a host value
|
|
52
|
+
* that is not a bare host, is left out, so a template that uses it reports it
|
|
53
|
+
* as unsatisfied; the reason is kept for that report.
|
|
54
|
+
*/
|
|
55
|
+
const getTemplateModuleVariables = (
|
|
56
|
+
moduleArg: object | undefined,
|
|
57
|
+
): { module: Record<string, unknown>; unusableReasons: Map<string, string> } => {
|
|
58
|
+
const module: Record<string, unknown> = {};
|
|
59
|
+
const unusableReasons = new Map<string, string>();
|
|
60
|
+
for (const [key, value] of Object.entries(moduleArg ?? {})) {
|
|
61
|
+
if (value === undefined || value === null) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (typeof value === 'string' && value.trim() === '') {
|
|
65
|
+
unusableReasons.set(`module.${key}`, 'is empty');
|
|
66
|
+
} else if (
|
|
67
|
+
templateHostKeys.includes(key) &&
|
|
68
|
+
!(typeof value === 'string' && templateHostPattern.test(value))
|
|
69
|
+
) {
|
|
70
|
+
unusableReasons.set(
|
|
71
|
+
`module.${key}`,
|
|
72
|
+
`is ${JSON.stringify(value)}, not a host (host[:port][/path], without a scheme or a trailing slash)`,
|
|
73
|
+
);
|
|
74
|
+
} else {
|
|
75
|
+
module[key] = value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { module, unusableReasons };
|
|
79
|
+
};
|
|
80
|
+
|
|
35
81
|
export class TemplatesFormatter extends BaseFormatter {
|
|
36
|
-
private
|
|
82
|
+
private templateWarnings: IFormatWarning[] = [];
|
|
37
83
|
|
|
38
84
|
get name(): string {
|
|
39
85
|
return 'templates';
|
|
40
86
|
}
|
|
41
87
|
|
|
42
88
|
async validate(): Promise<IFormatWarning[]> {
|
|
43
|
-
return this.
|
|
89
|
+
return this.templateWarnings;
|
|
44
90
|
}
|
|
45
91
|
|
|
46
92
|
/**
|
|
47
|
-
* Render a template directory
|
|
93
|
+
* Render a template directory into a map of path → content. Templates read
|
|
94
|
+
* `module` and `projectType` from the `@git.zone/cli` configuration.
|
|
48
95
|
*/
|
|
49
|
-
private async renderTemplate(templateName: string): Promise<
|
|
96
|
+
private async renderTemplate(templateName: string): Promise<TTemplateRenderOutcome> {
|
|
50
97
|
const templateDir = plugins.path.join(paths.templatesDir, templateName);
|
|
51
98
|
|
|
52
99
|
const scafTemplate = new ScafTemplate(templateDir);
|
|
53
100
|
await scafTemplate.readTemplateFromDir();
|
|
54
101
|
|
|
55
102
|
const gitzoneData = this.project.gitzoneConfig?.data;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
103
|
+
const { module, unusableReasons } = getTemplateModuleVariables(gitzoneData?.module);
|
|
104
|
+
await scafTemplate.supplyVariables({
|
|
105
|
+
module,
|
|
106
|
+
projectType: gitzoneData?.projectType,
|
|
107
|
+
});
|
|
108
|
+
if (scafTemplate.missingVariables.length > 0) {
|
|
109
|
+
return {
|
|
110
|
+
unsatisfiedReasons: scafTemplate.missingVariables.map(
|
|
111
|
+
(variableArg) =>
|
|
112
|
+
`@git.zone/cli.${variableArg} ${unusableReasons.get(variableArg) ?? 'is not set'}`,
|
|
113
|
+
),
|
|
114
|
+
};
|
|
61
115
|
}
|
|
62
116
|
|
|
63
117
|
const renderedFiles = await scafTemplate.renderToMemory();
|
|
@@ -66,14 +120,14 @@ export class TemplatesFormatter extends BaseFormatter {
|
|
|
66
120
|
for (const file of renderedFiles) {
|
|
67
121
|
fileMap.set(file.path, file.contents.toString());
|
|
68
122
|
}
|
|
69
|
-
return fileMap;
|
|
123
|
+
return { files: fileMap };
|
|
70
124
|
}
|
|
71
125
|
|
|
72
126
|
async analyze(): Promise<IPlannedChange[]> {
|
|
73
127
|
const changes: IPlannedChange[] = [];
|
|
74
128
|
const project = this.project;
|
|
75
129
|
const projectType = project.gitzoneConfig?.data?.projectType;
|
|
76
|
-
this.
|
|
130
|
+
this.templateWarnings = [];
|
|
77
131
|
|
|
78
132
|
// VSCode template - for all projects
|
|
79
133
|
const vscodeChanges = await this.analyzeTemplate('vscode', [
|
|
@@ -218,15 +272,27 @@ export class TemplatesFormatter extends BaseFormatter {
|
|
|
218
272
|
return changes;
|
|
219
273
|
}
|
|
220
274
|
|
|
221
|
-
let
|
|
275
|
+
let rendered: TTemplateRenderOutcome;
|
|
222
276
|
try {
|
|
223
|
-
|
|
277
|
+
rendered = await this.renderTemplate(templateName);
|
|
224
278
|
} catch (error) {
|
|
225
279
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
226
280
|
logVerbose(`Failed to render template ${templateName}: ${errorMessage}`);
|
|
227
281
|
return changes;
|
|
228
282
|
}
|
|
229
283
|
|
|
284
|
+
// An unrendered variable would be written as an empty string (a page
|
|
285
|
+
// linking `https:///fonts/fonts.css`), so the plan carries an error instead,
|
|
286
|
+
// which also keeps `gitzone format --write` from writing anything.
|
|
287
|
+
if ('unsatisfiedReasons' in rendered) {
|
|
288
|
+
const destPaths = files.map((fileArg) => fileArg.destPath).join(', ');
|
|
289
|
+
const message = `The ${templateName} template cannot render ${destPaths} from .smartconfig.json: ${rendered.unsatisfiedReasons.join('; ')}.`;
|
|
290
|
+
this.templateWarnings.push({ level: 'error', message, module: this.name });
|
|
291
|
+
logVerbose(message);
|
|
292
|
+
return changes;
|
|
293
|
+
}
|
|
294
|
+
const renderedFiles = rendered.files;
|
|
295
|
+
|
|
230
296
|
for (const file of files) {
|
|
231
297
|
// Look up by templatePath first, then destPath (frontmatter may rename files)
|
|
232
298
|
const processedContent = renderedFiles.get(file.templatePath)
|
|
@@ -256,7 +322,7 @@ export class TemplatesFormatter extends BaseFormatter {
|
|
|
256
322
|
// where the decision is made: in the plan the user confirms.
|
|
257
323
|
if (outcome.replacedReason) {
|
|
258
324
|
const replacementMessage = `${file.destPath} is replaced by the ${templateName} template instead of merged, because ${outcome.replacedReason}. Top-level keys only this project declares are lost.`;
|
|
259
|
-
this.
|
|
325
|
+
this.templateWarnings.push({
|
|
260
326
|
level: 'warning',
|
|
261
327
|
message: replacementMessage,
|
|
262
328
|
module: this.name,
|
|
@@ -39,7 +39,7 @@ export class TsconfigFormatter extends BaseFormatter {
|
|
|
39
39
|
// Get module paths from tspublish, merging with existing custom paths
|
|
40
40
|
const tspublishPaths: Record<string, string[]> = {};
|
|
41
41
|
try {
|
|
42
|
-
const tsPublishMod = await import('@git.zone/
|
|
42
|
+
const tsPublishMod = await import('@git.zone/tsrepo/publish');
|
|
43
43
|
const tsPublishInstance = new tsPublishMod.TsPublish();
|
|
44
44
|
const publishModules = await tsPublishInstance.getModuleSubDirs(paths.cwd);
|
|
45
45
|
|
package/ts/mod_format/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { TsconfigFormatter } from "./formatters/tsconfig.formatter.js";
|
|
|
28
28
|
import { PrettierFormatter } from "./formatters/prettier.formatter.js";
|
|
29
29
|
import { ReadmeFormatter } from "./formatters/readme.formatter.js";
|
|
30
30
|
import { CopyFormatter } from "./formatters/copy.formatter.js";
|
|
31
|
+
import { RustfmtFormatter } from "./formatters/rustfmt.formatter.js";
|
|
31
32
|
import type { ICheckResult, IFormatPlan } from "./interfaces.format.js";
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -73,6 +74,7 @@ const formatterMap: Record<
|
|
|
73
74
|
prettier: PrettierFormatter,
|
|
74
75
|
readme: ReadmeFormatter,
|
|
75
76
|
copy: CopyFormatter,
|
|
77
|
+
rustfmt: RustfmtFormatter,
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
// Formatters that don't require projectType to be set
|