@appsemble/cli 0.20.13 → 0.20.14
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/README.md +4 -4
- package/__fixtures__/getBlockConfigFromTypeScript/comments/tsconfig.json +1 -1
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateActions/tsconfig.json +1 -1
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateEventEmitters/tsconfig.json +1 -1
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateEventListeners/tsconfig.json +1 -1
- package/__fixtures__/getBlockConfigFromTypeScript/duplicateParameters/tsconfig.json +1 -1
- package/__fixtures__/getBlockConfigFromTypeScript/fontawesomeParameters/tsconfig.json +1 -1
- package/__fixtures__/getBlockConfigFromTypeScript/tsError/tsconfig.json +1 -1
- package/__fixtures__/getBlockConfigFromTypeScript/valid/tsconfig.json +1 -1
- package/commands/app/create.d.ts +1 -1
- package/commands/app/create.js +16 -24
- package/commands/app/create.js.map +1 -1
- package/commands/app/create.ts +3 -3
- package/commands/app/extract-messages.d.ts +1 -1
- package/commands/app/extract-messages.js +12 -20
- package/commands/app/extract-messages.js.map +1 -1
- package/commands/app/extract-messages.ts +2 -2
- package/commands/app/index.js +12 -36
- package/commands/app/index.js.map +1 -1
- package/commands/app/index.ts +9 -5
- package/commands/app/update.d.ts +1 -1
- package/commands/app/update.js +18 -26
- package/commands/app/update.js.map +1 -1
- package/commands/app/update.ts +4 -4
- package/commands/asset/create.d.ts +1 -1
- package/commands/asset/create.js +20 -28
- package/commands/asset/create.js.map +1 -1
- package/commands/asset/create.ts +4 -4
- package/commands/asset/index.js +5 -33
- package/commands/asset/index.js.map +1 -1
- package/commands/asset/index.ts +3 -3
- package/commands/block/build.d.ts +1 -1
- package/commands/block/build.js +14 -22
- package/commands/block/build.js.map +1 -1
- package/commands/block/build.ts +2 -2
- package/commands/block/extract-messages.d.ts +1 -1
- package/commands/block/extract-messages.js +15 -23
- package/commands/block/extract-messages.js.map +1 -1
- package/commands/block/extract-messages.ts +2 -2
- package/commands/block/index.js +12 -36
- package/commands/block/index.js.map +1 -1
- package/commands/block/index.ts +9 -5
- package/commands/block/publish.d.ts +1 -1
- package/commands/block/publish.js +17 -25
- package/commands/block/publish.js.map +1 -1
- package/commands/block/publish.ts +3 -3
- package/commands/cleanupResources.d.ts +1 -1
- package/commands/cleanupResources.js +6 -11
- package/commands/cleanupResources.js.map +1 -1
- package/commands/cleanupResources.ts +2 -2
- package/commands/config/get.d.ts +1 -1
- package/commands/config/get.js +10 -17
- package/commands/config/get.js.map +1 -1
- package/commands/config/get.ts +6 -5
- package/commands/config/index.js +10 -35
- package/commands/config/index.js.map +1 -1
- package/commands/config/index.ts +7 -4
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +15 -22
- package/commands/config/set.js.map +1 -1
- package/commands/config/set.ts +7 -6
- package/commands/login.d.ts +1 -1
- package/commands/login.js +3 -7
- package/commands/login.js.map +1 -1
- package/commands/login.ts +1 -1
- package/commands/logout.d.ts +1 -1
- package/commands/logout.js +3 -7
- package/commands/logout.js.map +1 -1
- package/commands/logout.ts +1 -1
- package/commands/migrate.d.ts +1 -1
- package/commands/migrate.js +8 -16
- package/commands/migrate.js.map +1 -1
- package/commands/migrate.ts +3 -3
- package/commands/organization/create.d.ts +1 -1
- package/commands/organization/create.js +10 -15
- package/commands/organization/create.js.map +1 -1
- package/commands/organization/create.ts +4 -4
- package/commands/organization/index.js +10 -35
- package/commands/organization/index.js.map +1 -1
- package/commands/organization/index.ts +7 -4
- package/commands/organization/update.d.ts +1 -1
- package/commands/organization/update.js +10 -15
- package/commands/organization/update.js.map +1 -1
- package/commands/organization/update.ts +4 -4
- package/commands/resource/create.d.ts +1 -1
- package/commands/resource/create.js +18 -26
- package/commands/resource/create.js.map +1 -1
- package/commands/resource/create.ts +4 -4
- package/commands/resource/index.js +10 -35
- package/commands/resource/index.js.map +1 -1
- package/commands/resource/index.ts +7 -4
- package/commands/resource/update.d.ts +1 -1
- package/commands/resource/update.js +18 -26
- package/commands/resource/update.js.map +1 -1
- package/commands/resource/update.ts +4 -4
- package/commands/runCronJobs.d.ts +1 -1
- package/commands/runCronJobs.js +6 -11
- package/commands/runCronJobs.js.map +1 -1
- package/commands/runCronJobs.ts +2 -2
- package/commands/start.d.ts +1 -1
- package/commands/start.js +10 -15
- package/commands/start.js.map +1 -1
- package/commands/start.ts +4 -4
- package/commands/team/create.d.ts +1 -1
- package/commands/team/create.js +10 -15
- package/commands/team/create.js.map +1 -1
- package/commands/team/create.ts +4 -4
- package/commands/team/delete.d.ts +1 -1
- package/commands/team/delete.js +10 -15
- package/commands/team/delete.js.map +1 -1
- package/commands/team/delete.ts +4 -4
- package/commands/team/index.js +14 -37
- package/commands/team/index.js.map +1 -1
- package/commands/team/index.ts +11 -6
- package/commands/team/member/delete.d.ts +1 -1
- package/commands/team/member/delete.js +10 -15
- package/commands/team/member/delete.js.map +1 -1
- package/commands/team/member/delete.ts +4 -4
- package/commands/team/member/index.js +12 -36
- package/commands/team/member/index.js.map +1 -1
- package/commands/team/member/index.ts +9 -5
- package/commands/team/member/invite.d.ts +1 -1
- package/commands/team/member/invite.js +10 -15
- package/commands/team/member/invite.js.map +1 -1
- package/commands/team/member/invite.ts +4 -4
- package/commands/team/member/update.d.ts +1 -1
- package/commands/team/member/update.js +12 -17
- package/commands/team/member/update.js.map +1 -1
- package/commands/team/member/update.ts +4 -4
- package/commands/team/update.d.ts +1 -1
- package/commands/team/update.js +10 -15
- package/commands/team/update.js.map +1 -1
- package/commands/team/update.ts +4 -4
- package/index.js +66 -94
- package/index.js.map +1 -1
- package/index.ts +65 -65
- package/jest.config.js +3 -1
- package/jest.setup.js +3 -5
- package/jest.setup.js.map +1 -1
- package/jest.setup.ts +1 -1
- package/lib/__snapshots__/getBlockConfigFromTypeScript.test.ts.snap +5 -6
- package/lib/app.d.ts +1 -1
- package/lib/app.js +151 -163
- package/lib/app.js.map +1 -1
- package/lib/app.ts +7 -7
- package/lib/asset.js +11 -18
- package/lib/asset.js.map +1 -1
- package/lib/authentication.d.ts +1 -1
- package/lib/authentication.js +34 -65
- package/lib/authentication.js.map +1 -1
- package/lib/authentication.ts +3 -2
- package/lib/block.js +99 -113
- package/lib/block.js.map +1 -1
- package/lib/block.test.js +9 -14
- package/lib/block.test.js.map +1 -1
- package/lib/block.test.ts +1 -1
- package/lib/block.ts +5 -5
- package/lib/coercers.js +5 -13
- package/lib/coercers.js.map +1 -1
- package/lib/coercers.test.js +2 -4
- package/lib/coercers.test.js.map +1 -1
- package/lib/coercers.test.ts +1 -1
- package/lib/getBlockConfigFromTypeScript.js +49 -56
- package/lib/getBlockConfigFromTypeScript.js.map +1 -1
- package/lib/getBlockConfigFromTypeScript.test.js +42 -46
- package/lib/getBlockConfigFromTypeScript.test.js.map +1 -1
- package/lib/getBlockConfigFromTypeScript.test.ts +7 -6
- package/lib/initAxios.d.ts +1 -1
- package/lib/initAxios.js +7 -14
- package/lib/initAxios.js.map +1 -1
- package/lib/initAxios.ts +2 -2
- package/lib/loadWebpackConfig.js +14 -45
- package/lib/loadWebpackConfig.js.map +1 -1
- package/lib/loadWebpackConfig.ts +10 -17
- package/lib/organization.js +23 -31
- package/lib/organization.js.map +1 -1
- package/lib/output.js +5 -9
- package/lib/output.js.map +1 -1
- package/lib/processCss.js +11 -18
- package/lib/processCss.js.map +1 -1
- package/lib/resource.js +17 -25
- package/lib/resource.js.map +1 -1
- package/lib/serverImport.js +6 -34
- package/lib/serverImport.js.map +1 -1
- package/lib/serverImport.ts +0 -1
- package/lib/team.js +28 -41
- package/lib/team.js.map +1 -1
- package/package.json +11 -10
- package/tsconfig.json +0 -1
- package/types.js +1 -2
package/lib/coercers.test.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const node_utils_1 = require("@appsemble/node-utils");
|
|
9
|
-
const comment_parser_1 = require("comment-parser");
|
|
10
|
-
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
11
|
-
const ts_json_schema_generator_1 = require("ts-json-schema-generator");
|
|
12
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
1
|
+
import { relative } from 'path';
|
|
2
|
+
import { AppsembleError, logger } from '@appsemble/node-utils';
|
|
3
|
+
import { parse } from 'comment-parser';
|
|
4
|
+
import normalizePath from 'normalize-path';
|
|
5
|
+
import { createFormatter, createParser, SchemaGenerator } from 'ts-json-schema-generator';
|
|
6
|
+
import ts from 'typescript';
|
|
13
7
|
/**
|
|
14
8
|
* Get the tsdoc comment for a TypeScript node.
|
|
15
9
|
*
|
|
@@ -49,12 +43,12 @@ function processInterface(iface, checker, convert) {
|
|
|
49
43
|
return Object.fromEntries(iface.members.map((member) => {
|
|
50
44
|
var _a;
|
|
51
45
|
const description = getNodeComments(checker, member);
|
|
52
|
-
if (
|
|
46
|
+
if (ts.isIndexSignatureDeclaration(member)) {
|
|
53
47
|
// Comments aren’t properly extracted for index signatures.
|
|
54
|
-
const commentRanges =
|
|
48
|
+
const commentRanges = ts.getLeadingCommentRanges(source, member.pos);
|
|
55
49
|
if (commentRanges) {
|
|
56
50
|
const comments = (_a = commentRanges === null || commentRanges === void 0 ? void 0 : commentRanges.map((r) => source.slice(r.pos, r.end))) !== null && _a !== void 0 ? _a : [];
|
|
57
|
-
const [block] =
|
|
51
|
+
const [block] = parse(comments[0]);
|
|
58
52
|
const processedDescription = block.source
|
|
59
53
|
.map((src) => src.tokens.description)
|
|
60
54
|
.join('\n')
|
|
@@ -63,16 +57,16 @@ function processInterface(iface, checker, convert) {
|
|
|
63
57
|
}
|
|
64
58
|
return convert(undefined, description);
|
|
65
59
|
}
|
|
66
|
-
if (!
|
|
67
|
-
throw new
|
|
60
|
+
if (!ts.isPropertySignature(member)) {
|
|
61
|
+
throw new AppsembleError(`Only property and index signatures are allowed as ${iface.name} keys. Found: ${member.getFullText()}`);
|
|
68
62
|
}
|
|
69
63
|
const { name } = member;
|
|
70
|
-
if (!
|
|
71
|
-
throw new
|
|
64
|
+
if (!ts.isIdentifier(name)) {
|
|
65
|
+
throw new AppsembleError(`Only property and index signatures are allowed as ${iface.name} keys. Found: ${name.getFullText()}`);
|
|
72
66
|
}
|
|
73
67
|
const { text } = name;
|
|
74
68
|
if (!/^[\da-z]+$/i.test(text)) {
|
|
75
|
-
throw new
|
|
69
|
+
throw new AppsembleError(`Found property named ‘${text}’ in ${iface.name} interface. Only alphanumerical identifiers are supported.`);
|
|
76
70
|
}
|
|
77
71
|
return convert(text, description);
|
|
78
72
|
}));
|
|
@@ -117,7 +111,7 @@ function processParameters(program, iface) {
|
|
|
117
111
|
if (!iface) {
|
|
118
112
|
return;
|
|
119
113
|
}
|
|
120
|
-
const formatter =
|
|
114
|
+
const formatter = createFormatter({}, (fmt) => {
|
|
121
115
|
fmt.addTypeFormatter({
|
|
122
116
|
supportsType: (type) => type.getName() === 'IconName',
|
|
123
117
|
getDefinition: () => ({ type: 'string', format: 'fontawesome' }),
|
|
@@ -129,8 +123,8 @@ function processParameters(program, iface) {
|
|
|
129
123
|
getChildren: () => [],
|
|
130
124
|
});
|
|
131
125
|
});
|
|
132
|
-
const parser =
|
|
133
|
-
const generator = new
|
|
126
|
+
const parser = createParser(program, { expose: 'all', topRef: false });
|
|
127
|
+
const generator = new SchemaGenerator(program, parser, formatter);
|
|
134
128
|
const schema = generator.createSchemaFromNodes([iface]);
|
|
135
129
|
if (schema.definitions && !Object.keys(schema.definitions).length) {
|
|
136
130
|
delete schema.definitions;
|
|
@@ -157,25 +151,25 @@ function processMessages(iface, checker) {
|
|
|
157
151
|
*/
|
|
158
152
|
function getProgram(blockPath) {
|
|
159
153
|
const diagnosticHost = {
|
|
160
|
-
getNewLine: () =>
|
|
161
|
-
getCurrentDirectory:
|
|
154
|
+
getNewLine: () => ts.sys.newLine,
|
|
155
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
162
156
|
getCanonicalFileName: (x) => x,
|
|
163
157
|
};
|
|
164
|
-
const tsConfigPath =
|
|
165
|
-
const { config, error } =
|
|
158
|
+
const tsConfigPath = ts.findConfigFile(blockPath, ts.sys.fileExists);
|
|
159
|
+
const { config, error } = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
166
160
|
if (error) {
|
|
167
|
-
throw new
|
|
161
|
+
throw new AppsembleError(ts.formatDiagnostic(error, diagnosticHost));
|
|
168
162
|
}
|
|
169
163
|
if (!config.files || !config.include) {
|
|
170
|
-
config.files =
|
|
164
|
+
config.files = ts.sys
|
|
171
165
|
.readDirectory(blockPath, ['.ts', '.tsx'])
|
|
172
|
-
.map((f) =>
|
|
166
|
+
.map((f) => relative(blockPath, f));
|
|
173
167
|
}
|
|
174
|
-
const { errors, fileNames, options } =
|
|
168
|
+
const { errors, fileNames, options } = ts.parseJsonConfigFileContent(config, ts.sys, blockPath, undefined, tsConfigPath);
|
|
175
169
|
// Filter: 'rootDir' is expected to contain all source files.
|
|
176
170
|
const diagnostics = errors.filter(({ code }) => code !== 6059);
|
|
177
171
|
if (diagnostics.length) {
|
|
178
|
-
throw new
|
|
172
|
+
throw new AppsembleError(ts.formatDiagnosticsWithColorAndContext(diagnostics, diagnosticHost));
|
|
179
173
|
}
|
|
180
174
|
options.noEmit = true;
|
|
181
175
|
delete options.out;
|
|
@@ -184,10 +178,10 @@ function getProgram(blockPath) {
|
|
|
184
178
|
delete options.declaration;
|
|
185
179
|
delete options.declarationDir;
|
|
186
180
|
delete options.declarationMap;
|
|
187
|
-
const program =
|
|
188
|
-
const preEmitDiagnostics =
|
|
181
|
+
const program = ts.createProgram(fileNames, options);
|
|
182
|
+
const preEmitDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
189
183
|
if (preEmitDiagnostics.length) {
|
|
190
|
-
throw new
|
|
184
|
+
throw new AppsembleError(ts.formatDiagnosticsWithColorAndContext(preEmitDiagnostics, diagnosticHost));
|
|
191
185
|
}
|
|
192
186
|
return program;
|
|
193
187
|
}
|
|
@@ -199,11 +193,11 @@ function getProgram(blockPath) {
|
|
|
199
193
|
* @param blockConfig The block configuration
|
|
200
194
|
* @returns The block configuration appended from the TypeScript project.
|
|
201
195
|
*/
|
|
202
|
-
function getBlockConfigFromTypeScript(blockConfig) {
|
|
196
|
+
export function getBlockConfigFromTypeScript(blockConfig) {
|
|
203
197
|
if ('actions' in blockConfig && 'events' in blockConfig && 'parameters' in blockConfig) {
|
|
204
198
|
return blockConfig;
|
|
205
199
|
}
|
|
206
|
-
|
|
200
|
+
logger.info(`Extracting data from TypeScript project ${blockConfig.dir}`);
|
|
207
201
|
const program = getProgram(blockConfig.dir);
|
|
208
202
|
const checker = program.getTypeChecker();
|
|
209
203
|
let actionInterface;
|
|
@@ -212,66 +206,66 @@ function getBlockConfigFromTypeScript(blockConfig) {
|
|
|
212
206
|
let messagesInterface;
|
|
213
207
|
let patametersInterface;
|
|
214
208
|
for (const sourceFile of program.getSourceFiles()) {
|
|
215
|
-
const fileName =
|
|
209
|
+
const fileName = relative(process.cwd(), sourceFile.fileName);
|
|
216
210
|
// Filter TypeScript default libs
|
|
217
211
|
if (program.isSourceFileDefaultLibrary(sourceFile)) {
|
|
218
|
-
|
|
212
|
+
logger.silly(`Skipping metadata extraction from: ${fileName}`);
|
|
219
213
|
continue;
|
|
220
214
|
}
|
|
221
|
-
|
|
215
|
+
logger.verbose(`Searching metadata in: ${fileName}`);
|
|
222
216
|
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
223
|
-
|
|
217
|
+
ts.forEachChild(sourceFile, (mod) => {
|
|
224
218
|
// This node doesn’t override SDK types
|
|
225
|
-
if (!
|
|
219
|
+
if (!ts.isModuleDeclaration(mod)) {
|
|
226
220
|
return;
|
|
227
221
|
}
|
|
228
222
|
// This module defines other types
|
|
229
223
|
if (mod.name.text !== '@appsemble/sdk') {
|
|
230
224
|
return;
|
|
231
225
|
}
|
|
232
|
-
|
|
226
|
+
ts.forEachChild(mod.body, (iface) => {
|
|
233
227
|
// Appsemble only uses module interface augmentation.
|
|
234
|
-
if (!
|
|
228
|
+
if (!ts.isInterfaceDeclaration(iface)) {
|
|
235
229
|
return;
|
|
236
230
|
}
|
|
237
231
|
const { line } = sourceFile.getLineAndCharacterOfPosition(iface.getStart(sourceFile));
|
|
238
232
|
// Line numbers are 0 indexed, whereas they are usually represented as 1 indexed.
|
|
239
|
-
const loc = `${(
|
|
233
|
+
const loc = `${normalizePath(fileName)}:${line + 1}`;
|
|
240
234
|
switch (iface.name.text) {
|
|
241
235
|
case 'Actions':
|
|
242
|
-
|
|
236
|
+
logger.info(`Found augmented interface 'Actions' in '${loc}'`);
|
|
243
237
|
if (actionInterface) {
|
|
244
|
-
throw new
|
|
238
|
+
throw new AppsembleError(`Found duplicate interface 'Actions' in '${loc}'`);
|
|
245
239
|
}
|
|
246
240
|
actionInterface = iface;
|
|
247
241
|
break;
|
|
248
242
|
case 'EventEmitters':
|
|
249
|
-
|
|
243
|
+
logger.info(`Found augmented interface 'EventEmitters' in '${loc}'`);
|
|
250
244
|
if (eventEmitterInterface) {
|
|
251
|
-
throw new
|
|
245
|
+
throw new AppsembleError(`Found duplicate interface 'EventEmitters' in '${loc}'`);
|
|
252
246
|
}
|
|
253
247
|
eventEmitterInterface = iface;
|
|
254
248
|
break;
|
|
255
249
|
case 'EventListeners':
|
|
256
|
-
|
|
250
|
+
logger.info(`Found augmented interface 'EventListeners' in '${loc}'`);
|
|
257
251
|
if (eventListenerInterface) {
|
|
258
|
-
throw new
|
|
252
|
+
throw new AppsembleError(`Found duplicate interface 'EventListeners' in '${loc}'`);
|
|
259
253
|
}
|
|
260
254
|
eventListenerInterface = iface;
|
|
261
255
|
break;
|
|
262
256
|
case 'Parameters':
|
|
263
|
-
|
|
257
|
+
logger.info(`Found augmented interface 'Parameters' in '${loc}'`);
|
|
264
258
|
if (patametersInterface) {
|
|
265
|
-
throw new
|
|
259
|
+
throw new AppsembleError(`Found duplicate interface 'Parameters' in '${loc}'`);
|
|
266
260
|
}
|
|
267
261
|
patametersInterface = iface;
|
|
268
262
|
break;
|
|
269
263
|
case 'Messages':
|
|
270
|
-
|
|
264
|
+
logger.info(`Found augmented interface 'Messages' in '${loc}'`);
|
|
271
265
|
messagesInterface = iface;
|
|
272
266
|
break;
|
|
273
267
|
default:
|
|
274
|
-
|
|
268
|
+
logger.warn(`Detected unused augmented type ${iface.name.text} in ${loc}`);
|
|
275
269
|
}
|
|
276
270
|
});
|
|
277
271
|
});
|
|
@@ -289,5 +283,4 @@ function getBlockConfigFromTypeScript(blockConfig) {
|
|
|
289
283
|
: processMessages(messagesInterface, checker),
|
|
290
284
|
};
|
|
291
285
|
}
|
|
292
|
-
exports.getBlockConfigFromTypeScript = getBlockConfigFromTypeScript;
|
|
293
286
|
//# sourceMappingURL=getBlockConfigFromTypeScript.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBlockConfigFromTypeScript.js","sourceRoot":"","sources":["getBlockConfigFromTypeScript.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBlockConfigFromTypeScript.js","sourceRoot":"","sources":["getBlockConfigFromTypeScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,OAAuB,EAAE,IAAoB;IACpE,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,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CAAC,QAAQ;YACtB,CAAC,CAAC,eAAe,CAAC,iBAAiB,EAAE,OAAO,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const node_utils_1 = require("@appsemble/node-utils");
|
|
9
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
10
|
-
const getBlockConfigFromTypeScript_1 = require("./getBlockConfigFromTypeScript");
|
|
1
|
+
import { readdirSync } from 'fs';
|
|
2
|
+
import process from 'process';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { AppsembleError, resolveFixture } from '@appsemble/node-utils';
|
|
5
|
+
import ts from 'typescript';
|
|
6
|
+
import { getBlockConfigFromTypeScript } from './getBlockConfigFromTypeScript.js';
|
|
11
7
|
beforeEach(() => {
|
|
12
|
-
jest.spyOn(process, 'cwd').mockReturnValue(
|
|
8
|
+
import.meta.jest.spyOn(process, 'cwd').mockReturnValue(resolveFixture('.'));
|
|
13
9
|
});
|
|
14
10
|
describe('getBlockConfigFromTypeScript', () => {
|
|
15
11
|
it('should extract configuration from a TypeScript project', () => {
|
|
16
|
-
const result =
|
|
12
|
+
const result = getBlockConfigFromTypeScript({
|
|
17
13
|
name: '',
|
|
18
14
|
layout: 'float',
|
|
19
15
|
version: '1.33.7',
|
|
20
16
|
webpack: '',
|
|
21
17
|
output: '',
|
|
22
|
-
dir:
|
|
18
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/valid'),
|
|
23
19
|
});
|
|
24
20
|
expect(result).toStrictEqual({
|
|
25
21
|
actions: { testAction: { description: undefined } },
|
|
@@ -54,7 +50,7 @@ describe('getBlockConfigFromTypeScript', () => {
|
|
|
54
50
|
});
|
|
55
51
|
});
|
|
56
52
|
it('should not use TypeScript if all metadata is present in the original config', () => {
|
|
57
|
-
jest.spyOn(
|
|
53
|
+
import.meta.jest.spyOn(ts, 'createProgram');
|
|
58
54
|
const input = {
|
|
59
55
|
actions: {},
|
|
60
56
|
events: { emit: { foo: {} }, listen: { bar: {} } },
|
|
@@ -63,87 +59,87 @@ describe('getBlockConfigFromTypeScript', () => {
|
|
|
63
59
|
version: '1.33.7',
|
|
64
60
|
webpack: '',
|
|
65
61
|
output: '',
|
|
66
|
-
dir:
|
|
62
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/valid'),
|
|
67
63
|
name: '',
|
|
68
64
|
};
|
|
69
|
-
const result =
|
|
65
|
+
const result = getBlockConfigFromTypeScript(input);
|
|
70
66
|
expect(result).toBe(input);
|
|
71
|
-
expect(
|
|
67
|
+
expect(ts.createProgram).not.toHaveBeenCalled();
|
|
72
68
|
});
|
|
73
69
|
it('should prefer actions overrides over TypeScript actions', () => {
|
|
74
|
-
const result =
|
|
70
|
+
const result = getBlockConfigFromTypeScript({
|
|
75
71
|
actions: {},
|
|
76
72
|
version: '1.33.7',
|
|
77
73
|
webpack: '',
|
|
78
74
|
output: '',
|
|
79
|
-
dir:
|
|
75
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/valid'),
|
|
80
76
|
name: '',
|
|
81
77
|
});
|
|
82
78
|
expect(result.actions).toStrictEqual({});
|
|
83
79
|
});
|
|
84
80
|
it('should prefer events overrides over TypeScript events', () => {
|
|
85
|
-
const result =
|
|
81
|
+
const result = getBlockConfigFromTypeScript({
|
|
86
82
|
events: { emit: { onSuccess: {} } },
|
|
87
83
|
version: '1.33.7',
|
|
88
84
|
webpack: '',
|
|
89
85
|
output: '',
|
|
90
|
-
dir:
|
|
86
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/valid'),
|
|
91
87
|
name: '',
|
|
92
88
|
});
|
|
93
89
|
expect(result.events).toStrictEqual({ emit: { onSuccess: {} } });
|
|
94
90
|
});
|
|
95
91
|
it('should prefer parameters overrides over TypeScript parameters', () => {
|
|
96
|
-
const result =
|
|
92
|
+
const result = getBlockConfigFromTypeScript({
|
|
97
93
|
parameters: { type: 'object' },
|
|
98
94
|
version: '1.33.7',
|
|
99
95
|
webpack: '',
|
|
100
96
|
output: '',
|
|
101
|
-
dir:
|
|
97
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/valid'),
|
|
102
98
|
name: '',
|
|
103
99
|
});
|
|
104
100
|
expect(result.parameters).toStrictEqual({ type: 'object' });
|
|
105
101
|
});
|
|
106
102
|
it('should throw if duplicate Actions are found', () => {
|
|
107
|
-
expect(() =>
|
|
103
|
+
expect(() => getBlockConfigFromTypeScript({
|
|
108
104
|
webpack: '',
|
|
109
105
|
output: '',
|
|
110
|
-
dir:
|
|
106
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/duplicateActions'),
|
|
111
107
|
name: '',
|
|
112
108
|
version: '1.33.7',
|
|
113
|
-
})).toThrow(new
|
|
109
|
+
})).toThrow(new AppsembleError("Found duplicate interface 'Actions' in 'getBlockConfigFromTypeScript/duplicateActions/index.ts:31'"));
|
|
114
110
|
});
|
|
115
111
|
it('should throw if duplicate EventEmitters are found', () => {
|
|
116
|
-
expect(() =>
|
|
112
|
+
expect(() => getBlockConfigFromTypeScript({
|
|
117
113
|
webpack: '',
|
|
118
114
|
output: '',
|
|
119
|
-
dir:
|
|
115
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/duplicateEventEmitters'),
|
|
120
116
|
name: '',
|
|
121
117
|
version: '1.33.7',
|
|
122
|
-
})).toThrow(new
|
|
118
|
+
})).toThrow(new AppsembleError("Found duplicate interface 'EventEmitters' in 'getBlockConfigFromTypeScript/duplicateEventEmitters/index.ts:31'"));
|
|
123
119
|
});
|
|
124
120
|
it('should throw if duplicate EventListeners are found', () => {
|
|
125
|
-
expect(() =>
|
|
121
|
+
expect(() => getBlockConfigFromTypeScript({
|
|
126
122
|
webpack: '',
|
|
127
123
|
output: '',
|
|
128
|
-
dir:
|
|
124
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/duplicateEventListeners'),
|
|
129
125
|
name: '',
|
|
130
126
|
version: '1.33.7',
|
|
131
|
-
})).toThrow(new
|
|
127
|
+
})).toThrow(new AppsembleError("Found duplicate interface 'EventListeners' in 'getBlockConfigFromTypeScript/duplicateEventListeners/index.ts:31'"));
|
|
132
128
|
});
|
|
133
129
|
it('should throw if duplicate Parameters are found', () => {
|
|
134
|
-
expect(() =>
|
|
130
|
+
expect(() => getBlockConfigFromTypeScript({
|
|
135
131
|
webpack: '',
|
|
136
132
|
output: '',
|
|
137
|
-
dir:
|
|
133
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/duplicateParameters'),
|
|
138
134
|
name: '',
|
|
139
135
|
version: '1.33.7',
|
|
140
|
-
})).toThrow(new
|
|
136
|
+
})).toThrow(new AppsembleError("Found duplicate interface 'Parameters' in 'getBlockConfigFromTypeScript/duplicateParameters/index.ts:31'"));
|
|
141
137
|
});
|
|
142
138
|
it('should handle fontawesome icons', () => {
|
|
143
|
-
const result =
|
|
139
|
+
const result = getBlockConfigFromTypeScript({
|
|
144
140
|
webpack: '',
|
|
145
141
|
output: '',
|
|
146
|
-
dir:
|
|
142
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/fontawesomeParameters'),
|
|
147
143
|
name: '',
|
|
148
144
|
version: '1.33.7',
|
|
149
145
|
});
|
|
@@ -163,26 +159,26 @@ describe('getBlockConfigFromTypeScript', () => {
|
|
|
163
159
|
});
|
|
164
160
|
it('should handle TypeScript pre emit diagnostics', () => {
|
|
165
161
|
function fn() {
|
|
166
|
-
|
|
162
|
+
getBlockConfigFromTypeScript({
|
|
167
163
|
name: '',
|
|
168
164
|
layout: 'float',
|
|
169
165
|
version: '1.33.7',
|
|
170
166
|
webpack: '',
|
|
171
167
|
output: '',
|
|
172
|
-
dir:
|
|
168
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/tsError'),
|
|
173
169
|
});
|
|
174
170
|
}
|
|
175
|
-
expect(fn).toThrow(
|
|
171
|
+
expect(fn).toThrow(AppsembleError);
|
|
176
172
|
expect(fn).toThrow(/'unused' is declared but its value is never read/);
|
|
177
173
|
});
|
|
178
174
|
it('should extract comments', () => {
|
|
179
|
-
const result =
|
|
175
|
+
const result = getBlockConfigFromTypeScript({
|
|
180
176
|
name: '',
|
|
181
177
|
layout: 'float',
|
|
182
178
|
version: '1.33.7',
|
|
183
179
|
webpack: '',
|
|
184
180
|
output: '',
|
|
185
|
-
dir:
|
|
181
|
+
dir: resolveFixture('getBlockConfigFromTypeScript/comments'),
|
|
186
182
|
});
|
|
187
183
|
expect(result).toStrictEqual({
|
|
188
184
|
actions: {
|
|
@@ -221,10 +217,10 @@ describe('getBlockConfigFromTypeScript', () => {
|
|
|
221
217
|
});
|
|
222
218
|
});
|
|
223
219
|
describe('official blocks', () => {
|
|
224
|
-
const blocksDir =
|
|
225
|
-
it.each(
|
|
226
|
-
const dir = (
|
|
227
|
-
const result =
|
|
220
|
+
const blocksDir = new URL('../../../blocks/', import.meta.url);
|
|
221
|
+
it.each(readdirSync(blocksDir))('%s', (name) => {
|
|
222
|
+
const dir = fileURLToPath(new URL(name, blocksDir));
|
|
223
|
+
const result = getBlockConfigFromTypeScript({
|
|
228
224
|
name,
|
|
229
225
|
version: '',
|
|
230
226
|
output: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBlockConfigFromTypeScript.test.js","sourceRoot":"","sources":["getBlockConfigFromTypeScript.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBlockConfigFromTypeScript.test.js","sourceRoot":"","sources":["getBlockConfigFromTypeScript.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,O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IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;YAEpD,MAAM,MAAM,GAAG,4BAA4B,CAAC;gBAC1C,IAAI;gBACJ,OAAO,EAAE,EAAE;gBACX,MAAM,EAAE,EAAE;gBACV,OAAO,EAAE,SAAS;gBAClB,GAAG;aACJ,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { readdirSync } from 'fs';
|
|
2
|
-
import
|
|
2
|
+
import process from 'process';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
3
4
|
|
|
4
5
|
import { AppsembleError, resolveFixture } from '@appsemble/node-utils';
|
|
5
6
|
import ts from 'typescript';
|
|
6
7
|
|
|
7
|
-
import { getBlockConfigFromTypeScript } from './getBlockConfigFromTypeScript';
|
|
8
|
+
import { getBlockConfigFromTypeScript } from './getBlockConfigFromTypeScript.js';
|
|
8
9
|
|
|
9
10
|
beforeEach(() => {
|
|
10
|
-
jest.spyOn(process, 'cwd').mockReturnValue(resolveFixture('.'));
|
|
11
|
+
import.meta.jest.spyOn(process, 'cwd').mockReturnValue(resolveFixture('.'));
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
describe('getBlockConfigFromTypeScript', () => {
|
|
@@ -54,7 +55,7 @@ describe('getBlockConfigFromTypeScript', () => {
|
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
it('should not use TypeScript if all metadata is present in the original config', () => {
|
|
57
|
-
jest.spyOn(ts, 'createProgram');
|
|
58
|
+
import.meta.jest.spyOn(ts, 'createProgram');
|
|
58
59
|
const input = {
|
|
59
60
|
actions: {},
|
|
60
61
|
events: { emit: { foo: {} }, listen: { bar: {} } },
|
|
@@ -262,10 +263,10 @@ describe('getBlockConfigFromTypeScript', () => {
|
|
|
262
263
|
});
|
|
263
264
|
|
|
264
265
|
describe('official blocks', () => {
|
|
265
|
-
const blocksDir =
|
|
266
|
+
const blocksDir = new URL('../../../blocks/', import.meta.url);
|
|
266
267
|
|
|
267
268
|
it.each(readdirSync(blocksDir))('%s', (name) => {
|
|
268
|
-
const dir =
|
|
269
|
+
const dir = fileURLToPath(new URL(name, blocksDir));
|
|
269
270
|
|
|
270
271
|
const result = getBlockConfigFromTypeScript({
|
|
271
272
|
name,
|
package/lib/initAxios.d.ts
CHANGED
package/lib/initAxios.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initAxios = void 0;
|
|
7
|
-
const node_utils_1 = require("@appsemble/node-utils");
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
1
|
+
import { configureAxios, logger } from '@appsemble/node-utils';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import pkg from '../package.json' assert { type: 'json' };
|
|
10
4
|
/**
|
|
11
5
|
* Configure the default axios URL.
|
|
12
6
|
*
|
|
13
7
|
* @param argv The parsed command line arguments.
|
|
14
8
|
*/
|
|
15
|
-
function initAxios({ remote }) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
export function initAxios({ remote }) {
|
|
10
|
+
axios.defaults.baseURL = remote;
|
|
11
|
+
logger.verbose(`Request remote set to ${remote}`);
|
|
12
|
+
configureAxios('AppsembleCLI', pkg.version);
|
|
19
13
|
}
|
|
20
|
-
exports.initAxios = initAxios;
|
|
21
14
|
//# sourceMappingURL=initAxios.js.map
|
package/lib/initAxios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initAxios.js","sourceRoot":"","sources":["initAxios.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initAxios.js","sourceRoot":"","sources":["initAxios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,GAAG,MAAM,iBAAiB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;AAG1D;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,MAAM,EAAiB;IACjD,KAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,OAAO,CAAC,yBAAyB,MAAM,EAAE,CAAC,CAAC;IAClD,cAAc,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC"}
|
package/lib/initAxios.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { configureAxios, logger } from '@appsemble/node-utils';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
|
|
4
|
-
import pkg from '../package.json';
|
|
5
|
-
import { BaseArguments } from '../types';
|
|
4
|
+
import pkg from '../package.json' assert { type: 'json' };
|
|
5
|
+
import { BaseArguments } from '../types.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Configure the default axios URL.
|