@apso/cli 0.37.0 → 0.37.1
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.
|
@@ -6,6 +6,7 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
6
6
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
7
|
const lib_1 = require("../lib");
|
|
8
8
|
const base_command_1 = tslib_1.__importDefault(require("../lib/base-command"));
|
|
9
|
+
const interactive_1 = require("../lib/utils/interactive");
|
|
9
10
|
const perf_hooks_1 = require("perf_hooks");
|
|
10
11
|
const file_system_1 = require("../lib/utils/file-system");
|
|
11
12
|
const git_hooks_1 = require("../lib/utils/git-hooks");
|
|
@@ -26,6 +27,11 @@ class Generate extends base_command_1.default {
|
|
|
26
27
|
console.log(`[apso] Using language from .apsorc: ${language}`);
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
30
|
+
// Headless (CI / no TTY / APSO_NONINTERACTIVE): never block on a prompt.
|
|
31
|
+
// Fail fast and name the flag so the caller can retry deterministically.
|
|
32
|
+
if (!(0, interactive_1.isInteractive)()) {
|
|
33
|
+
this.error((0, interactive_1.missingFlag)('Pass --language <typescript|python|go> or set "language" in .apsorc.'));
|
|
34
|
+
}
|
|
29
35
|
const implementedLanguages = (0, lib_1.getImplementedLanguages)();
|
|
30
36
|
const { selectedLanguage } = await inquirer_1.default.prompt([
|
|
31
37
|
{
|
|
@@ -14,6 +14,20 @@ export declare const PROJECT_NAME_PATTERN: RegExp;
|
|
|
14
14
|
* Removes the .git directory after cloning.
|
|
15
15
|
*/
|
|
16
16
|
export declare function cloneTemplate(projectPath: string, language: TargetLanguage, log: (msg: string) => void): void;
|
|
17
|
+
/**
|
|
18
|
+
* Stamp the chosen language into the scaffolded `.apsorc`.
|
|
19
|
+
*
|
|
20
|
+
* `apso generate` resolves its target language as flag > .apsorc > prompt.
|
|
21
|
+
* The TypeScript template (pinned at v2.0.0) ships an `.apsorc` without a
|
|
22
|
+
* `language` field, so a bare `apso generate` right after `apso init` fell
|
|
23
|
+
* through to the interactive prompt — which errors in non-TTY contexts
|
|
24
|
+
* (this is what kept the weekly scaffold-smoke workflow red). Recording the
|
|
25
|
+
* language `init` was given makes the scaffold self-describing.
|
|
26
|
+
*
|
|
27
|
+
* Best-effort: leaves an existing `language` value alone and skips files it
|
|
28
|
+
* cannot parse as JSON.
|
|
29
|
+
*/
|
|
30
|
+
export declare function stampApsorcLanguage(projectPath: string, language: TargetLanguage, log: (msg: string) => void): void;
|
|
17
31
|
/**
|
|
18
32
|
* Ensure the scaffolded project has a `.env` file.
|
|
19
33
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initGitRepo = exports.ensureEnvFile = exports.cloneTemplate = exports.PROJECT_NAME_PATTERN = exports.TEMPLATE_REFS = exports.TEMPLATE_REPOS = void 0;
|
|
3
|
+
exports.initGitRepo = exports.ensureEnvFile = exports.stampApsorcLanguage = exports.cloneTemplate = exports.PROJECT_NAME_PATTERN = exports.TEMPLATE_REFS = exports.TEMPLATE_REPOS = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
@@ -49,8 +49,43 @@ function cloneTemplate(projectPath, language, log) {
|
|
|
49
49
|
}
|
|
50
50
|
shelljs_1.default.rm("-rf", path.join(projectPath, ".git"));
|
|
51
51
|
ensureEnvFile(projectPath, log);
|
|
52
|
+
stampApsorcLanguage(projectPath, language, log);
|
|
52
53
|
}
|
|
53
54
|
exports.cloneTemplate = cloneTemplate;
|
|
55
|
+
/**
|
|
56
|
+
* Stamp the chosen language into the scaffolded `.apsorc`.
|
|
57
|
+
*
|
|
58
|
+
* `apso generate` resolves its target language as flag > .apsorc > prompt.
|
|
59
|
+
* The TypeScript template (pinned at v2.0.0) ships an `.apsorc` without a
|
|
60
|
+
* `language` field, so a bare `apso generate` right after `apso init` fell
|
|
61
|
+
* through to the interactive prompt — which errors in non-TTY contexts
|
|
62
|
+
* (this is what kept the weekly scaffold-smoke workflow red). Recording the
|
|
63
|
+
* language `init` was given makes the scaffold self-describing.
|
|
64
|
+
*
|
|
65
|
+
* Best-effort: leaves an existing `language` value alone and skips files it
|
|
66
|
+
* cannot parse as JSON.
|
|
67
|
+
*/
|
|
68
|
+
function stampApsorcLanguage(projectPath, language, log) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const apsorcPath = path.join(projectPath, ".apsorc");
|
|
71
|
+
if (!fs.existsSync(apsorcPath))
|
|
72
|
+
return;
|
|
73
|
+
try {
|
|
74
|
+
const raw = fs.readFileSync(apsorcPath, "utf-8");
|
|
75
|
+
const config = JSON.parse(raw);
|
|
76
|
+
if (config.language)
|
|
77
|
+
return;
|
|
78
|
+
config.language = language;
|
|
79
|
+
const indent = (_b = (_a = raw.match(/^([\t ]+)"/m)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : " ";
|
|
80
|
+
fs.writeFileSync(apsorcPath, `${JSON.stringify(config, null, indent)}\n`);
|
|
81
|
+
log(`Recorded "language": "${language}" in .apsorc`);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// .apsorc may use a format we don't fully parse (e.g. comments) —
|
|
85
|
+
// leave it untouched rather than risk mangling the user's schema file.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.stampApsorcLanguage = stampApsorcLanguage;
|
|
54
89
|
/**
|
|
55
90
|
* Ensure the scaffolded project has a `.env` file.
|
|
56
91
|
*
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apso/cli",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@apso/cli",
|
|
9
|
-
"version": "0.37.
|
|
9
|
+
"version": "0.37.1",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@biomejs/biome": "^1.9.4",
|
package/oclif.manifest.json
CHANGED