@axinom/mosaic-cli 0.10.2-rc.7 → 0.11.0-rc.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/cli/index.js
CHANGED
|
@@ -15,28 +15,7 @@ const run = () => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
|
15
15
|
yargs
|
|
16
16
|
.scriptName('mosaic')
|
|
17
17
|
.env()
|
|
18
|
-
.command(
|
|
19
|
-
yargs
|
|
20
|
-
.option('only', {
|
|
21
|
-
alias: 'o',
|
|
22
|
-
describe: 'A glob where files should be searched within.\n(Note: the script will attach "/*.template" to the given value)',
|
|
23
|
-
string: true,
|
|
24
|
-
default: '**',
|
|
25
|
-
})
|
|
26
|
-
.option('replace', {
|
|
27
|
-
alias: 'r',
|
|
28
|
-
describe: 'Defines whether already existing target files will be overwritten or not.',
|
|
29
|
-
default: false,
|
|
30
|
-
boolean: true,
|
|
31
|
-
})
|
|
32
|
-
.option('yes', {
|
|
33
|
-
alias: 'y',
|
|
34
|
-
type: 'boolean',
|
|
35
|
-
describe: 'If set to true, the script will not prompt for a user confirmation when overwriting files.',
|
|
36
|
-
default: false,
|
|
37
|
-
boolean: true,
|
|
38
|
-
});
|
|
39
|
-
}, apply_templates_1.applyTemplates)
|
|
18
|
+
.command(apply_templates_1.applyTemplates)
|
|
40
19
|
.command(get_access_token_1.getAccessToken)
|
|
41
20
|
.command(publish_schema_to_db_1.publishSchemaToDb)
|
|
42
21
|
.command(pg_dump_1.pgDump)
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,iEAA6D;AAC7D,iFAG6C;AAC7C,mEAA8D;AAC9D,2DAAuD;AACvD,yDAAqD;AACrD,mDAA+C;AAC/C,iDAA6C;AAC7C,2EAAqE;AAE9D,MAAM,GA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,GAAG,OAiCd"}
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Diff from 'diff';
|
|
2
|
+
import { CommandModule } from 'yargs';
|
|
3
|
+
export interface ApplyTemplatesOptions {
|
|
2
4
|
only: string;
|
|
3
|
-
replace: boolean;
|
|
4
5
|
yes: boolean;
|
|
5
|
-
|
|
6
|
+
no: boolean;
|
|
7
|
+
verbose: boolean;
|
|
8
|
+
replace: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DiffResult {
|
|
11
|
+
result: 'created' | 'same' | 'different' | 'differentLayout';
|
|
12
|
+
diff: Diff.Change[];
|
|
13
|
+
}
|
|
14
|
+
export declare const applyTemplates: CommandModule<unknown, ApplyTemplatesOptions>;
|
|
15
|
+
export declare class ConfigTemplate {
|
|
16
|
+
readonly file: string;
|
|
17
|
+
readonly target: string;
|
|
18
|
+
readonly targetExists: boolean;
|
|
19
|
+
constructor(file: string);
|
|
20
|
+
compare(_: boolean): DiffResult;
|
|
21
|
+
writeTarget(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare class EnvConfigTemplate extends ConfigTemplate {
|
|
24
|
+
constructor(file: string);
|
|
25
|
+
private mergeContent;
|
|
26
|
+
compare(verbose: boolean): DiffResult;
|
|
27
|
+
writeTarget(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function compareTemplate(template: ConfigTemplate, verbose?: boolean): 'created' | 'same' | 'different' | 'differentLayout';
|
|
@@ -1,94 +1,277 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyTemplates = void 0;
|
|
4
|
-
|
|
3
|
+
exports.compareTemplate = exports.EnvConfigTemplate = exports.ConfigTemplate = exports.applyTemplates = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
5
|
/* eslint-disable no-console */
|
|
6
6
|
const chalk_1 = require("chalk");
|
|
7
7
|
const Diff = require("diff");
|
|
8
|
+
const envfile = require("envfile");
|
|
8
9
|
const fs_1 = require("fs");
|
|
9
10
|
const glob = require("glob");
|
|
10
11
|
const readline = require("readline");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const yargs = require("yargs");
|
|
13
|
+
exports.applyTemplates = {
|
|
14
|
+
command: 'apply-templates',
|
|
15
|
+
describe: 'Creates a local copy of each *.template file. ' +
|
|
16
|
+
'A diff and confirmation prompt will be displayed before any changes are made. ' +
|
|
17
|
+
'Env (.env) files have special treatment... the value for each key defined in the target file will be kept in these cases:\n' +
|
|
18
|
+
' a. A value for the key is not defined, or is blank, in the template\n' +
|
|
19
|
+
' b. The value in the template looks like <a_{placeholder}>\n' +
|
|
20
|
+
' c. The line from the template is included in the .env file and commented out',
|
|
21
|
+
builder: (yargs) => yargs
|
|
22
|
+
.option('only', {
|
|
23
|
+
alias: 'o',
|
|
24
|
+
describe: 'A glob where files should be searched within.\n(Note: the script will attach "/*.template" to the given value)',
|
|
25
|
+
string: true,
|
|
26
|
+
default: '**',
|
|
27
|
+
})
|
|
28
|
+
.option('yes', {
|
|
29
|
+
alias: ['y'],
|
|
30
|
+
describe: 'The script will overwrite files without prompting for user confirmation.',
|
|
31
|
+
default: false,
|
|
32
|
+
boolean: true,
|
|
33
|
+
})
|
|
34
|
+
.option('no', {
|
|
35
|
+
alias: 'n',
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
describe: 'The script will not overwrite any files.',
|
|
38
|
+
default: false,
|
|
39
|
+
boolean: true,
|
|
40
|
+
})
|
|
41
|
+
.option('verbose', {
|
|
42
|
+
alias: 'v',
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
describe: 'List all files and show all diff lines.',
|
|
45
|
+
default: false,
|
|
46
|
+
boolean: true,
|
|
47
|
+
})
|
|
48
|
+
.option('replace', {
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
describe: 'Replace all files reverting to template values. WARNING: this is destructive!',
|
|
51
|
+
default: false,
|
|
52
|
+
boolean: true,
|
|
53
|
+
}),
|
|
54
|
+
handler: compareTemplates,
|
|
55
|
+
};
|
|
56
|
+
class ConfigTemplate {
|
|
57
|
+
constructor(file) {
|
|
58
|
+
this.file = file;
|
|
59
|
+
this.target = file.slice(0, -9); // remove `.template` from the filename
|
|
60
|
+
this.targetExists = (0, fs_1.existsSync)(this.target);
|
|
61
|
+
}
|
|
62
|
+
compare(_) {
|
|
63
|
+
const content = (0, fs_1.readFileSync)(this.file).toString();
|
|
64
|
+
const targetContent = (0, fs_1.readFileSync)(this.target).toString();
|
|
65
|
+
const diff = Diff.diffLines(targetContent, content);
|
|
66
|
+
const changes = diff.filter((d) => d.added || d.removed);
|
|
67
|
+
return {
|
|
68
|
+
result: changes.length ? 'different' : 'same',
|
|
69
|
+
diff,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
writeTarget() {
|
|
73
|
+
(0, fs_1.copyFileSync)(this.file, this.target);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.ConfigTemplate = ConfigTemplate;
|
|
77
|
+
class EnvConfigTemplate extends ConfigTemplate {
|
|
78
|
+
constructor(file) {
|
|
79
|
+
super(file);
|
|
80
|
+
}
|
|
81
|
+
mergeContent() {
|
|
82
|
+
const content = (0, fs_1.readFileSync)(this.file).toString();
|
|
83
|
+
if (!this.targetExists) {
|
|
84
|
+
return content;
|
|
85
|
+
}
|
|
86
|
+
const targetContent = (0, fs_1.readFileSync)(this.target).toString();
|
|
87
|
+
const vars = envfile.parse(content);
|
|
88
|
+
const targetVars = envfile.parse(targetContent);
|
|
89
|
+
let mergedContent = content;
|
|
90
|
+
let additionalContent = '';
|
|
91
|
+
for (const [k, v] of Object.entries(targetVars)) {
|
|
92
|
+
// if key is not in template, then append target value to merged content
|
|
93
|
+
if (!(k in vars)) {
|
|
94
|
+
additionalContent += `\n${envfile.stringify({ [k]: v })}`;
|
|
95
|
+
}
|
|
96
|
+
else if (vars[k] !== v) {
|
|
97
|
+
const commented = targetContent.match(new RegExp(`(?<=(\n|^))#${k}=`));
|
|
98
|
+
// use target value if template value looks like a placeholder
|
|
99
|
+
// use target value if key is also included as a comment
|
|
100
|
+
if (isPlaceholder(vars[k]) || vars[k] === '' || commented) {
|
|
101
|
+
// keep commented template value (updated with current template value)
|
|
102
|
+
const commentPrefix = commented
|
|
103
|
+
? '#' + envfile.stringify({ [k]: vars[k] })
|
|
104
|
+
: '';
|
|
105
|
+
mergedContent = mergedContent.replace(new RegExp(`(?<=(\n|^))${k}=.*?(\r?\n|$)`), commentPrefix + envfile.stringify({ [k]: vars[k], [k]: v }));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (additionalContent !== '') {
|
|
110
|
+
mergedContent += `\n\n# Additional keys (not in template)${additionalContent}`;
|
|
111
|
+
}
|
|
112
|
+
return mergedContent;
|
|
113
|
+
}
|
|
114
|
+
compare(verbose) {
|
|
115
|
+
const content = this.mergeContent();
|
|
116
|
+
const targetContent = (0, fs_1.readFileSync)(this.target).toString();
|
|
117
|
+
let diff = [];
|
|
118
|
+
if (content !== targetContent) {
|
|
119
|
+
// diff of sorted values
|
|
120
|
+
diff = Diff.diffLines(envfile.stringify(orderByKey(envfile.parse(targetContent))), envfile.stringify(orderByKey(envfile.parse(content)))).filter((d) => d.added || d.removed);
|
|
121
|
+
}
|
|
122
|
+
const result = content === targetContent
|
|
123
|
+
? 'same'
|
|
124
|
+
: diff.length > 0
|
|
125
|
+
? 'different'
|
|
126
|
+
: 'differentLayout';
|
|
127
|
+
if (result !== 'same' && verbose) {
|
|
128
|
+
// full diff of all lines
|
|
129
|
+
diff = Diff.diffLines(targetContent, content);
|
|
130
|
+
}
|
|
131
|
+
return { result, diff };
|
|
132
|
+
}
|
|
133
|
+
writeTarget() {
|
|
134
|
+
if (!this.targetExists) {
|
|
135
|
+
(0, fs_1.copyFileSync)(this.file, this.target);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const mergedContent = this.mergeContent();
|
|
139
|
+
(0, fs_1.writeFileSync)(this.target, mergedContent);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.EnvConfigTemplate = EnvConfigTemplate;
|
|
143
|
+
/*
|
|
144
|
+
* Use glob to iterate matching files.
|
|
145
|
+
*/
|
|
146
|
+
function compareTemplates(options) {
|
|
147
|
+
const templatesPath = `${options.only}/*.template`;
|
|
148
|
+
const results = {
|
|
149
|
+
created: [],
|
|
150
|
+
same: [],
|
|
151
|
+
different: [],
|
|
152
|
+
differentLayout: [],
|
|
153
|
+
};
|
|
154
|
+
glob(templatesPath, { dot: true, ignore: '**/node_modules/**' }, (err, files) => {
|
|
155
|
+
if (err) {
|
|
156
|
+
console.log(err);
|
|
157
|
+
process.exit(-1);
|
|
158
|
+
}
|
|
159
|
+
for (const f of files) {
|
|
160
|
+
const isEnv = isEnvFile(f);
|
|
161
|
+
const template = isEnv && !options.replace
|
|
162
|
+
? new EnvConfigTemplate(f)
|
|
163
|
+
: new ConfigTemplate(f);
|
|
164
|
+
const resultKey = compareTemplate(template, options.verbose);
|
|
165
|
+
results[resultKey].push(template);
|
|
166
|
+
}
|
|
167
|
+
const total = results.created.length +
|
|
168
|
+
results.same.length +
|
|
169
|
+
results.different.length +
|
|
170
|
+
results.differentLayout.length;
|
|
171
|
+
console.log(`Found ${total} template file${total !== 1 ? 's' : ''}. ${results.created.length} target file${results.created.length !== 1 ? 's were' : ' was'} created. ${results.different.length + results.differentLayout.length} target file${results.different.length + results.differentLayout.length !== 1
|
|
172
|
+
? 's have'
|
|
173
|
+
: ' has'} changes`);
|
|
174
|
+
if (results.different.length !== 0) {
|
|
175
|
+
promptChanges();
|
|
176
|
+
}
|
|
16
177
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
178
|
+
function promptChanges() {
|
|
179
|
+
if (options.yes) {
|
|
180
|
+
writeOutputFiles();
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
else if (options.no) {
|
|
184
|
+
console.log('Changes not applied.');
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const rl = readline.createInterface({
|
|
188
|
+
input: process.stdin,
|
|
189
|
+
output: process.stdout,
|
|
190
|
+
});
|
|
191
|
+
console.log((0, chalk_1.yellow)("NOTE: To prevent changes to .env files from being overwritten, don't remove or replace the original line but comment it out."));
|
|
192
|
+
rl.question((0, chalk_1.cyanBright)(`Do you want to apply the changes above? (y/N)\n`), (answer) => {
|
|
21
193
|
if (answer === 'y') {
|
|
22
|
-
|
|
194
|
+
writeOutputFiles();
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
console.log('Changes not applied.');
|
|
23
198
|
}
|
|
24
199
|
rl.close();
|
|
25
200
|
});
|
|
26
201
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
202
|
+
function writeOutputFiles() {
|
|
203
|
+
for (const template of results.different) {
|
|
204
|
+
console.log(`Applying ${template.file} => ${template.target}`);
|
|
205
|
+
template.writeTarget();
|
|
206
|
+
}
|
|
207
|
+
console.log(`Changes applied to ${results.different.length} file${results.different.length !== 1 ? 's' : ''}!`);
|
|
30
208
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
files.forEach((file) => {
|
|
43
|
-
result.checked += 1;
|
|
44
|
-
const target = file.slice(0, -9);
|
|
45
|
-
if (!options.replace) {
|
|
46
|
-
if (exists(target)) {
|
|
47
|
-
const diff = compare(file, target);
|
|
48
|
-
if (diff.length > 1) {
|
|
49
|
-
console.log((0, chalk_1.yellow)(`Skipping ${file} but target file already existing, but with different content:`));
|
|
50
|
-
diff.forEach((part) => {
|
|
51
|
-
const color = part.added
|
|
52
|
-
? chalk_1.green
|
|
53
|
-
: part.removed
|
|
54
|
-
? chalk_1.red
|
|
55
|
-
: chalk_1.grey;
|
|
56
|
-
const prefix = part.added ? '+ ' : part.removed ? '- ' : ' ';
|
|
57
|
-
process.stdout.write(color(part.value.replace(/(.*)\n/g, `${prefix}$1\n`)));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
result.skipped += 1;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// File not existing
|
|
64
|
-
console.log((0, chalk_1.yellow)(`Applying ${file} => ${target}`));
|
|
65
|
-
(0, fs_1.copyFileSync)(file, target);
|
|
66
|
-
result.written += 1;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
console.log((0, chalk_1.yellow)(`Applying ${file} => ${target}`));
|
|
71
|
-
(0, fs_1.copyFileSync)(file, target);
|
|
72
|
-
result.written += 1;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
console.log((0, chalk_1.yellow)(`Found ${result.checked} file${result.checked !== 1 ? 's' : ''}. ${result.written} file${result.written !== 1 ? 's' : ''} applied, ${result.skipped} file${result.skipped !== 1 ? 's' : ''} skipped!`));
|
|
76
|
-
}));
|
|
209
|
+
}
|
|
210
|
+
/*
|
|
211
|
+
* Compare a single template and custom file with target file.
|
|
212
|
+
* If target file doesn't exist then create it.
|
|
213
|
+
* If both exist and there are differences, return 'different' and do nothing.
|
|
214
|
+
*/
|
|
215
|
+
function compareTemplate(template, verbose = false) {
|
|
216
|
+
if (!template.targetExists) {
|
|
217
|
+
template.writeTarget();
|
|
218
|
+
console.log(`Target file ${template.target} did not exist and has been created.`);
|
|
219
|
+
return 'created';
|
|
77
220
|
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
221
|
+
const { result, diff } = template.compare(verbose);
|
|
222
|
+
if (result === 'same') {
|
|
223
|
+
if (verbose) {
|
|
224
|
+
console.log((0, chalk_1.gray)(`File ${template.target} has no changes.`));
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
console.log((0, chalk_1.cyanBright)(`File ${template.target} has changes${verbose ? '' : ' (Use -v to show full diff)'}:`));
|
|
229
|
+
if (result === 'differentLayout' && !verbose) {
|
|
230
|
+
console.log((0, chalk_1.gray)(` (Changes to whitespace, comments and line-order only)`));
|
|
231
|
+
return result;
|
|
84
232
|
}
|
|
85
|
-
|
|
86
|
-
|
|
233
|
+
logDiffLines(diff);
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
exports.compareTemplate = compareTemplate;
|
|
237
|
+
function logDiffLines(diff) {
|
|
238
|
+
for (const part of diff) {
|
|
239
|
+
let value = part.value;
|
|
240
|
+
// last line without newline causes formatting issues
|
|
241
|
+
if (value !== '' && !value.endsWith('\n')) {
|
|
242
|
+
value += '\n';
|
|
243
|
+
}
|
|
244
|
+
const color = part.added ? chalk_1.green : part.removed ? chalk_1.red : chalk_1.white;
|
|
245
|
+
const prefix = part.added ? '+ ' : part.removed ? '- ' : ' ';
|
|
246
|
+
value = value.replace(/(.*)\n/g, `${prefix}$1\n`);
|
|
247
|
+
process.stdout.write(color(value));
|
|
87
248
|
}
|
|
88
249
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
250
|
+
/*
|
|
251
|
+
* Determine if the file is a .env file. Matches globs *.env.* & *.env
|
|
252
|
+
*/
|
|
253
|
+
function isEnvFile(file) {
|
|
254
|
+
return file.match(/.env\b/) ? true : false;
|
|
255
|
+
}
|
|
256
|
+
/*
|
|
257
|
+
* Determine if a value looks like a placeholder
|
|
258
|
+
*/
|
|
259
|
+
function isPlaceholder(value) {
|
|
260
|
+
// placeholders look like: <{aaa}> or <aaa{bbb}>
|
|
261
|
+
return value.match(/^<[^>]*?\{[^>]*?\}[^>]*?>$/) ? true : false;
|
|
262
|
+
}
|
|
263
|
+
// Dev helper. Script can be run directly with command (without building the lib):
|
|
264
|
+
// yarn ts-node libs/cli/src/commands/apply-templates.ts apply-templates
|
|
265
|
+
if (require.main === module) {
|
|
266
|
+
yargs.command(exports.applyTemplates).demandCommand().argv;
|
|
267
|
+
}
|
|
268
|
+
/** Orders an object by keys */
|
|
269
|
+
function orderByKey(unordered) {
|
|
270
|
+
return Object.keys(unordered)
|
|
271
|
+
.sort()
|
|
272
|
+
.reduce((obj, key) => {
|
|
273
|
+
obj[key] = unordered[key];
|
|
274
|
+
return obj;
|
|
275
|
+
}, {});
|
|
93
276
|
}
|
|
94
277
|
//# sourceMappingURL=apply-templates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-templates.js","sourceRoot":"","sources":["../../src/commands/apply-templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apply-templates.js","sourceRoot":"","sources":["../../src/commands/apply-templates.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,+BAA+B;AAC/B,iCAA2E;AAC3E,6BAA6B;AAC7B,mCAAmC;AACnC,2BAA2E;AAC3E,6BAA6B;AAC7B,qCAAqC;AACrC,+BAA+B;AAgBlB,QAAA,cAAc,GAAkD;IAC3E,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EACN,gDAAgD;QAChD,gFAAgF;QAChF,6HAA6H;QAC7H,wEAAwE;QACxE,8DAA8D;QAC9D,+EAA+E;IACjF,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,MAAM,CAAC,MAAM,EAAE;QACd,KAAK,EAAE,GAAG;QACV,QAAQ,EACN,gHAAgH;QAClH,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,CAAC,KAAK,EAAE;QACb,KAAK,EAAE,CAAC,GAAG,CAAC;QACZ,QAAQ,EACN,0EAA0E;QAC5E,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,CAAC,IAAI,EAAE;QACZ,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,SAAS;QACf,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": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -24,20 +24,23 @@
|
|
|
24
24
|
"dev": "tsc --watch",
|
|
25
25
|
"test": "jest",
|
|
26
26
|
"test:ci": "jest --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura --coverageReporters=html",
|
|
27
|
+
"test:cov": "jest --coverage --silent && yarn posttest:cov",
|
|
28
|
+
"posttest:cov": "ts-node ../../scripts/open-test-coverage.ts -- libs/cli",
|
|
27
29
|
"lint": "eslint . --ext .ts,.tsx,.js --color --cache"
|
|
28
30
|
},
|
|
29
31
|
"dependencies": {
|
|
30
32
|
"@asyncapi/diff": "^0.4.0",
|
|
31
33
|
"@asyncapi/modelina": "^0.43.0",
|
|
32
34
|
"@asyncapi/parser": "^1.15.0",
|
|
33
|
-
"@axinom/mosaic-id-link-be": "^0.6.7-rc.
|
|
34
|
-
"@axinom/mosaic-service-common": "^0.20.0-rc.
|
|
35
|
+
"@axinom/mosaic-id-link-be": "^0.6.7-rc.10",
|
|
36
|
+
"@axinom/mosaic-service-common": "^0.20.0-rc.3",
|
|
35
37
|
"@graphql-inspector/core": "^3.1.2",
|
|
36
38
|
"@stoplight/spectral": "^5.9.1",
|
|
37
39
|
"chalk": "^4.1.0",
|
|
38
40
|
"diff": "^5.0.0",
|
|
39
41
|
"dotenv": "^8.2.0",
|
|
40
42
|
"endent": "^2.0.1",
|
|
43
|
+
"envfile": "^6.17.0",
|
|
41
44
|
"find-nearest-file": "^1.1.0",
|
|
42
45
|
"glob": "^7.1.6",
|
|
43
46
|
"graphile-build": "^4.12.0",
|
|
@@ -64,5 +67,5 @@
|
|
|
64
67
|
"publishConfig": {
|
|
65
68
|
"access": "public"
|
|
66
69
|
},
|
|
67
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "b71ab6d3de6c740255ea18b889cfdf62f4ec1c57"
|
|
68
71
|
}
|