@apso/cli 0.46.1 → 0.46.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/commands/migrate.js +10 -2
- package/dist/lib/generators/base.js +1 -1
- package/dist/lib/generators/typescript.js +1 -3
- package/dist/lib/templates/guards/api-key-auth.guard.eta +0 -1
- package/dist/lib/templates/guards/auth.guard.eta +0 -1
- package/dist/lib/templates/guards/guards.module.eta +0 -1
- package/dist/lib/templates/guards/jwt-auth.guard.eta +0 -1
- package/dist/lib/utils/file-system.d.ts +0 -4
- package/dist/lib/utils/file-system.js +1 -9
- package/npm-shrinkwrap.json +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/dist/commands/migrate.js
CHANGED
|
@@ -124,8 +124,16 @@ class Migrate extends base_command_1.default {
|
|
|
124
124
|
verified = result.ok;
|
|
125
125
|
if (!this.json)
|
|
126
126
|
(0, verify_1.report)((s) => this.log(s), { ...result, findings: [] }, false);
|
|
127
|
-
if (!result.ok)
|
|
128
|
-
|
|
127
|
+
if (!result.ok) {
|
|
128
|
+
// Don't keep a migration that failed: the next run would read it as
|
|
129
|
+
// deployed and find nothing to migrate. The working plan keeps the
|
|
130
|
+
// answers and the baseline, so a rerun picks up where this one stopped.
|
|
131
|
+
for (const f of [written.file, written.planFile])
|
|
132
|
+
fs.rmSync(path.resolve(cwd, f), { force: true });
|
|
133
|
+
save();
|
|
134
|
+
const planRel = path.relative(cwd, planPath);
|
|
135
|
+
this.fail(`The migration failed its test, so it was not kept. Change an answer in ${planRel} or the .apsorc, then run apso migrate again. If the data loss is intended, rerun with --accept-loss <table.column>.`, { plan: planRel, steps: result.steps });
|
|
136
|
+
}
|
|
129
137
|
}
|
|
130
138
|
this.say(`\nReview and commit ${written.file} and ${written.planFile}, then deploy.`);
|
|
131
139
|
if (verified === true && !flags.seed)
|
|
@@ -40,7 +40,7 @@ class BaseGenerator {
|
|
|
40
40
|
* Render a template file with the given data
|
|
41
41
|
*/
|
|
42
42
|
async renderTemplate(templatePath, data) {
|
|
43
|
-
const content = await this.templateEngine.renderFileAsync(templatePath,
|
|
43
|
+
const content = await this.templateEngine.renderFileAsync(templatePath, data);
|
|
44
44
|
return content;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
6
|
const Eta = tslib_1.__importStar(require("eta"));
|
|
7
7
|
const base_1 = require("./base");
|
|
8
|
-
// Utilities available for future use: createFile
|
|
8
|
+
// Utilities available for future use: createFile from "../utils/file-system"
|
|
9
9
|
const field_1 = require("../utils/field");
|
|
10
10
|
const relationships_1 = require("../utils/relationships");
|
|
11
11
|
const parse_1 = require("../utils/relationships/parse");
|
|
@@ -365,8 +365,6 @@ class TypeScriptGenerator extends base_1.BaseGenerator {
|
|
|
365
365
|
authEntities,
|
|
366
366
|
jwt,
|
|
367
367
|
apiKey,
|
|
368
|
-
generatedAt: new Date().toISOString(),
|
|
369
|
-
generatedBy: "Apso CLI",
|
|
370
368
|
};
|
|
371
369
|
// Generate auth.guard.ts if auth is configured
|
|
372
370
|
if (hasAuth) {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* AuthGuard - application API keys stored as SHA-256 hashes on <%= it.apiKey.apiKeyEntity %>
|
|
3
3
|
*
|
|
4
4
|
* Auto-generated by Apso CLI from .apsorc auth configuration
|
|
5
|
-
* Generated at: <%= it.generatedAt %>
|
|
6
5
|
*
|
|
7
6
|
* This guard:
|
|
8
7
|
* - Reads the key from the <%= it.apiKey.apiKeyHeader %> header
|
|
@@ -31,7 +31,6 @@ import { <%= entity %> } from '../<%= entity %>/<%= entity %>.entity';
|
|
|
31
31
|
* GuardsModule provides authentication and scope-based data isolation guards.
|
|
32
32
|
*
|
|
33
33
|
* Auto-generated from .apsorc configuration.
|
|
34
|
-
* Generated at: <%= it.generatedAt %>
|
|
35
34
|
*
|
|
36
35
|
* Usage:
|
|
37
36
|
* 1. Import GuardsModule in your AppModule
|
|
@@ -8,7 +8,3 @@ export declare const createFile: (file: string, content: string) => Promise<void
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const removeStaleGeneratedFiles: (dir: string, keep: Set<string>) => string[];
|
|
10
10
|
export declare const createDirectoryContents: (templatePath: string, newProjectPath: string, apiType: string) => void;
|
|
11
|
-
export declare function withGeneratedMeta<T extends object>(data: T): T & {
|
|
12
|
-
generatedAt: string;
|
|
13
|
-
generatedBy: string;
|
|
14
|
-
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createDirectoryContents = exports.removeStaleGeneratedFiles = exports.createFile = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
6
|
const fs = tslib_1.__importStar(require("fs"));
|
|
@@ -80,11 +80,3 @@ const writeFile = (fileName, origFilePath, writePath, mode, apiType) => {
|
|
|
80
80
|
fs.chmodSync(fileWritePath, mode);
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
function withGeneratedMeta(data) {
|
|
84
|
-
return {
|
|
85
|
-
...data,
|
|
86
|
-
generatedAt: new Date().toISOString(),
|
|
87
|
-
generatedBy: process.env.USER || process.env.USERNAME || "unknown",
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
exports.withGeneratedMeta = withGeneratedMeta;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apso/cli",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@apso/cli",
|
|
9
|
-
"version": "0.46.
|
|
9
|
+
"version": "0.46.3",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@apso/schema-tools": "^0.2.0",
|
package/oclif.manifest.json
CHANGED