@apso/cli 0.41.0 → 0.41.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.
|
@@ -10,6 +10,7 @@ const interactive_1 = require("../lib/utils/interactive");
|
|
|
10
10
|
const perf_hooks_1 = require("perf_hooks");
|
|
11
11
|
const file_system_1 = require("../lib/utils/file-system");
|
|
12
12
|
const git_hooks_1 = require("../lib/utils/git-hooks");
|
|
13
|
+
const crud_deps_1 = require("../lib/utils/crud-deps");
|
|
13
14
|
class Generate extends base_command_1.default {
|
|
14
15
|
async run() {
|
|
15
16
|
var _a, _b;
|
|
@@ -240,6 +241,15 @@ class Generate extends base_command_1.default {
|
|
|
240
241
|
else if (generatedFileCount === 0) {
|
|
241
242
|
console.log("[apso] Skipping formatting (no files were generated)");
|
|
242
243
|
}
|
|
244
|
+
// Generated TS code imports @apso/crud*. Projects from the v1 template
|
|
245
|
+
// (@nestjsx/crud) don't declare those, and every entity then fails to
|
|
246
|
+
// compile with TS2307. Declare them so the next install picks them up.
|
|
247
|
+
if (language === "typescript" && generatedFileCount > 0) {
|
|
248
|
+
const added = (0, crud_deps_1.ensureCrudDeps)(process.cwd());
|
|
249
|
+
if (added.length > 0) {
|
|
250
|
+
console.log(`[apso] Added ${added.join(", ")} to package.json (the generated code imports them). Run npm install before building.`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
243
253
|
const totalBuildTime = perf_hooks_1.performance.now() - totalBuildStart;
|
|
244
254
|
console.log(`[apso] Finished building all entities in ${totalBuildTime.toFixed(2)} ms`);
|
|
245
255
|
// Best-effort: install the commit co-author hook so commits that include
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime packages the generated TypeScript code imports (entities, services,
|
|
3
|
+
* controllers, guards). Versions match the pinned service-template-ts tag
|
|
4
|
+
* (see TEMPLATE_REFS in ./template.ts); bump both together.
|
|
5
|
+
*/
|
|
6
|
+
export declare const APSO_CRUD_DEPS: Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Add any missing @apso/crud runtime packages to the project's package.json.
|
|
9
|
+
*
|
|
10
|
+
* Projects created from the v1 template (@nestjsx/crud) don't declare them, so
|
|
11
|
+
* freshly generated code fails `nest build` with TS2307 "Cannot find module
|
|
12
|
+
* '@apso/crud'" on every entity. Existing @nestjsx deps are left alone because
|
|
13
|
+
* hand-written code may still import them.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} projectDir - Directory holding the project's package.json.
|
|
16
|
+
* @returns {string[]} Names added (empty when nothing changed or no package.json).
|
|
17
|
+
*/
|
|
18
|
+
export declare function ensureCrudDeps(projectDir: string): string[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureCrudDeps = exports.APSO_CRUD_DEPS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
7
|
+
/**
|
|
8
|
+
* Runtime packages the generated TypeScript code imports (entities, services,
|
|
9
|
+
* controllers, guards). Versions match the pinned service-template-ts tag
|
|
10
|
+
* (see TEMPLATE_REFS in ./template.ts); bump both together.
|
|
11
|
+
*/
|
|
12
|
+
exports.APSO_CRUD_DEPS = {
|
|
13
|
+
"@apso/crud": "^1.0.1",
|
|
14
|
+
"@apso/crud-core": "^1.0.1",
|
|
15
|
+
"@apso/crud-request": "^1.0.1",
|
|
16
|
+
"@apso/crud-typeorm": "^1.0.1",
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Add any missing @apso/crud runtime packages to the project's package.json.
|
|
20
|
+
*
|
|
21
|
+
* Projects created from the v1 template (@nestjsx/crud) don't declare them, so
|
|
22
|
+
* freshly generated code fails `nest build` with TS2307 "Cannot find module
|
|
23
|
+
* '@apso/crud'" on every entity. Existing @nestjsx deps are left alone because
|
|
24
|
+
* hand-written code may still import them.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} projectDir - Directory holding the project's package.json.
|
|
27
|
+
* @returns {string[]} Names added (empty when nothing changed or no package.json).
|
|
28
|
+
*/
|
|
29
|
+
function ensureCrudDeps(projectDir) {
|
|
30
|
+
var _a;
|
|
31
|
+
const pkgPath = path.join(projectDir, "package.json");
|
|
32
|
+
if (!fs.existsSync(pkgPath))
|
|
33
|
+
return [];
|
|
34
|
+
const raw = fs.readFileSync(pkgPath, "utf8");
|
|
35
|
+
const pkg = JSON.parse(raw);
|
|
36
|
+
const declared = { ...pkg.devDependencies, ...pkg.dependencies };
|
|
37
|
+
const missing = Object.keys(exports.APSO_CRUD_DEPS).filter((name) => !declared[name]);
|
|
38
|
+
if (missing.length === 0)
|
|
39
|
+
return [];
|
|
40
|
+
pkg.dependencies = (_a = pkg.dependencies) !== null && _a !== void 0 ? _a : {};
|
|
41
|
+
for (const name of missing)
|
|
42
|
+
pkg.dependencies[name] = exports.APSO_CRUD_DEPS[name];
|
|
43
|
+
pkg.dependencies = Object.fromEntries(Object.entries(pkg.dependencies).sort(([a], [b]) => a.localeCompare(b)));
|
|
44
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + (raw.endsWith("\n") ? "\n" : ""));
|
|
45
|
+
return missing;
|
|
46
|
+
}
|
|
47
|
+
exports.ensureCrudDeps = ensureCrudDeps;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apso/cli",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@apso/cli",
|
|
9
|
-
"version": "0.41.
|
|
9
|
+
"version": "0.41.1",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@apso/schema-tools": "^0.2.0",
|
package/oclif.manifest.json
CHANGED