@player-tools/cli 0.4.2-next.1 → 0.5.0-next.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/commands/dependency-versions/check.d.ts +18 -0
- package/dist/commands/dependency-versions/check.js +271 -0
- package/dist/commands/dsl/compile.d.ts +2 -2
- package/dist/commands/dsl/compile.js +136 -141
- package/dist/commands/dsl/validate.d.ts +12 -0
- package/dist/commands/dsl/validate.js +76 -0
- package/dist/commands/json/validate.d.ts +1 -1
- package/dist/commands/json/validate.js +62 -73
- package/dist/commands/xlr/compile.d.ts +1 -1
- package/dist/commands/xlr/compile.js +73 -79
- package/dist/commands/xlr/convert.d.ts +1 -1
- package/dist/commands/xlr/convert.js +59 -68
- package/dist/config.d.ts +2 -2
- package/dist/config.js +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -18
- package/dist/plugins/LSPAssetsPlugin.d.ts +2 -2
- package/dist/plugins/LSPAssetsPlugin.js +3 -13
- package/dist/plugins/LSPPluginPlugin.d.ts +2 -2
- package/dist/plugins/LSPPluginPlugin.js +3 -13
- package/dist/plugins/LSPTransformsPlugin.d.ts +3 -3
- package/dist/plugins/LSPTransformsPlugin.js +3 -13
- package/dist/plugins/index.d.ts +9 -9
- package/dist/plugins/index.js +5 -17
- package/dist/utils/babel-register.js +8 -9
- package/dist/utils/base-command.d.ts +7 -7
- package/dist/utils/base-command.js +107 -136
- package/dist/utils/compilation-context.d.ts +2 -2
- package/dist/utils/compilation-context.js +3 -11
- package/dist/utils/compile-renderer.d.ts +2 -2
- package/dist/utils/compile-renderer.js +14 -16
- package/dist/utils/compiler-options.d.ts +3 -0
- package/dist/utils/compiler-options.js +16 -0
- package/dist/utils/diag-renderer.d.ts +2 -2
- package/dist/utils/diag-renderer.js +35 -36
- package/dist/utils/fs.js +4 -5
- package/dist/utils/task-runner.d.ts +4 -4
- package/dist/utils/task-runner.js +15 -22
- package/dist/utils/xlr/consts.js +9 -8
- package/dist/utils/xlr/visitors/file.d.ts +2 -2
- package/dist/utils/xlr/visitors/file.js +6 -7
- package/dist/utils/xlr/visitors/index.d.ts +3 -3
- package/dist/utils/xlr/visitors/index.js +5 -17
- package/dist/utils/xlr/visitors/plugin.d.ts +2 -2
- package/dist/utils/xlr/visitors/plugin.js +29 -37
- package/dist/utils/xlr/visitors/types.d.ts +2 -2
- package/dist/utils/xlr/visitors/types.js +1 -0
- package/package.json +46 -36
- package/oclif.manifest.json +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const globby_1 = tslib_1.__importDefault(require("globby"));
|
|
5
|
+
const log_symbols_1 = tslib_1.__importDefault(require("log-symbols"));
|
|
6
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
|
+
const core_1 = require("@oclif/core");
|
|
8
|
+
const base_command_1 = require("../../utils/base-command");
|
|
9
|
+
const fs_1 = require("../../utils/fs");
|
|
10
|
+
const compiler_options_1 = require("../../utils/compiler-options");
|
|
11
|
+
/** A command thay runs TS typechecker against source ts and tsx files */
|
|
12
|
+
class Validate extends base_command_1.BaseCommand {
|
|
13
|
+
async getOptions() {
|
|
14
|
+
const { flags } = await this.parse(Validate);
|
|
15
|
+
const config = await this.getPlayerConfig();
|
|
16
|
+
const files = flags.files && flags.files.length > 0 ? flags.files : config.dsl?.src;
|
|
17
|
+
if (!files) {
|
|
18
|
+
throw new Error("DSL TSC typechecking requires a file list");
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
inputFiles: Array.isArray(files) ? files : [files],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async run() {
|
|
25
|
+
const { inputFiles } = await this.getOptions();
|
|
26
|
+
const files = await (0, globby_1.default)((0, fs_1.convertToFileGlob)(inputFiles, "**/*.(tsx|jsx|js|ts)"), {
|
|
27
|
+
expandDirectories: true,
|
|
28
|
+
});
|
|
29
|
+
const program = ts.createProgram(files, compiler_options_1.DEFAULT_COMPILER_OPTIONS);
|
|
30
|
+
const allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
31
|
+
let diagnosticsCount = 0;
|
|
32
|
+
const groupedDiagnostics = allDiagnostics.reduce((acc, diagnostic) => {
|
|
33
|
+
const fileName = diagnostic.file?.fileName;
|
|
34
|
+
if (fileName && files.includes(fileName)) {
|
|
35
|
+
if (!acc[fileName]) {
|
|
36
|
+
acc[fileName] = [];
|
|
37
|
+
}
|
|
38
|
+
acc[fileName].push(diagnostic);
|
|
39
|
+
diagnosticsCount += 1;
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
const fileNameList = Object.keys(groupedDiagnostics);
|
|
44
|
+
fileNameList.forEach((diagnosticGroup) => {
|
|
45
|
+
this.log(`${diagnosticGroup}`);
|
|
46
|
+
groupedDiagnostics[diagnosticGroup].forEach((diagnostic) => {
|
|
47
|
+
if (diagnostic.file) {
|
|
48
|
+
const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
|
49
|
+
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
50
|
+
this.log(` ${log_symbols_1.default.error} (${line + 1},${character + 1}): ${message}`);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
if (fileNameList.length) {
|
|
58
|
+
this.log(`${diagnosticsCount} type or syntax errors found in ${fileNameList.length} file${fileNameList.length > 1 ? "s" : ""}, exiting program`);
|
|
59
|
+
this.exit(1);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.log(`${log_symbols_1.default.success} No TSX types or errors found.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
Validate.description = "Validate TSX files before they get compiled";
|
|
67
|
+
Validate.flags = {
|
|
68
|
+
...base_command_1.BaseCommand.flags,
|
|
69
|
+
files: core_1.Flags.string({
|
|
70
|
+
char: "f",
|
|
71
|
+
description: "A list of files or globs to validate",
|
|
72
|
+
multiple: true,
|
|
73
|
+
}),
|
|
74
|
+
};
|
|
75
|
+
exports.default = Validate;
|
|
76
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
15
4
|
const core_1 = require("@oclif/core");
|
|
16
|
-
const globby_1 = __importDefault(require("globby"));
|
|
5
|
+
const globby_1 = tslib_1.__importDefault(require("globby"));
|
|
17
6
|
const fs_1 = require("fs");
|
|
18
7
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
19
8
|
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
@@ -23,69 +12,69 @@ const fs_2 = require("../../utils/fs");
|
|
|
23
12
|
const task_runner_1 = require("../../utils/task-runner");
|
|
24
13
|
/** A command to validate JSON content */
|
|
25
14
|
class Validate extends base_command_1.BaseCommand {
|
|
26
|
-
getOptions() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
exp,
|
|
39
|
-
};
|
|
40
|
-
});
|
|
15
|
+
async getOptions() {
|
|
16
|
+
const { flags } = await this.parse(Validate);
|
|
17
|
+
const config = await this.getPlayerConfig();
|
|
18
|
+
const files = flags.files && flags.files.length > 0 ? flags.files : config.json?.src;
|
|
19
|
+
const { exp } = flags;
|
|
20
|
+
if (!files) {
|
|
21
|
+
throw new Error("JSON validation requires a file list");
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
files: Array.isArray(files) ? files : [files],
|
|
25
|
+
exp,
|
|
26
|
+
};
|
|
41
27
|
}
|
|
42
|
-
run() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})),
|
|
68
|
-
});
|
|
69
|
-
const taskResults = yield taskRunner.run();
|
|
70
|
-
taskResults.forEach((t) => {
|
|
71
|
-
if (t.error ||
|
|
72
|
-
t.output.some((d) => d.severity === vscode_languageserver_types_1.DiagnosticSeverity.Error)) {
|
|
73
|
-
results.exitCode = 100;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
this.debug('finished');
|
|
77
|
-
this.exit(results.exitCode);
|
|
78
|
-
return results;
|
|
28
|
+
async run() {
|
|
29
|
+
const { files: inputFiles, exp } = await this.getOptions();
|
|
30
|
+
const expandedFilesList = (0, fs_2.convertToFileGlob)(inputFiles, "**/*.json");
|
|
31
|
+
this.debug("Searching for files using: %o", expandedFilesList);
|
|
32
|
+
const files = await (0, globby_1.default)(expandedFilesList, {
|
|
33
|
+
expandDirectories: true,
|
|
34
|
+
});
|
|
35
|
+
this.debug("Found %i files to process", files.length);
|
|
36
|
+
const results = {
|
|
37
|
+
exitCode: 0,
|
|
38
|
+
};
|
|
39
|
+
const lsp = await this.createLanguageService(exp);
|
|
40
|
+
const taskRunner = (0, task_runner_1.createTaskRunner)({
|
|
41
|
+
renderer: diag_renderer_1.validationRenderer,
|
|
42
|
+
tasks: files.map((f) => ({
|
|
43
|
+
data: {
|
|
44
|
+
file: f,
|
|
45
|
+
},
|
|
46
|
+
run: async () => {
|
|
47
|
+
const contents = await fs_1.promises.readFile(f, "utf-8");
|
|
48
|
+
const lsp = await this.createLanguageService(exp);
|
|
49
|
+
const validations = (await lsp.validateTextDocument(vscode_languageserver_textdocument_1.TextDocument.create(`file://${f}`, "json", 1, contents))) ?? [];
|
|
50
|
+
return validations;
|
|
51
|
+
},
|
|
52
|
+
})),
|
|
79
53
|
});
|
|
54
|
+
const taskResults = await taskRunner.run();
|
|
55
|
+
taskResults.forEach((t) => {
|
|
56
|
+
if (t.error ||
|
|
57
|
+
t.output.some((d) => d.severity === vscode_languageserver_types_1.DiagnosticSeverity.Error)) {
|
|
58
|
+
results.exitCode = 100;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
this.debug("finished");
|
|
62
|
+
this.exit(results.exitCode);
|
|
63
|
+
return results;
|
|
80
64
|
}
|
|
81
65
|
}
|
|
82
|
-
|
|
83
|
-
Validate.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
Validate.description = "Validate Player JSON content";
|
|
67
|
+
Validate.flags = {
|
|
68
|
+
...base_command_1.BaseCommand.flags,
|
|
69
|
+
files: core_1.Flags.string({
|
|
70
|
+
char: "f",
|
|
71
|
+
description: "A list of files or globs to validate",
|
|
87
72
|
multiple: true,
|
|
88
|
-
}),
|
|
89
|
-
|
|
73
|
+
}),
|
|
74
|
+
exp: core_1.Flags.boolean({
|
|
75
|
+
description: "Use experimental language features",
|
|
90
76
|
default: false,
|
|
91
|
-
})
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
exports.default = Validate;
|
|
80
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
15
4
|
const core_1 = require("@oclif/core");
|
|
16
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
17
|
-
const fs_1 = __importDefault(require("fs"));
|
|
18
|
-
const path_1 = __importDefault(require("path"));
|
|
19
|
-
const globby_1 = __importDefault(require("globby"));
|
|
20
|
-
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const globby_1 = tslib_1.__importDefault(require("globby"));
|
|
9
|
+
const log_symbols_1 = tslib_1.__importDefault(require("log-symbols"));
|
|
21
10
|
const xlr_converters_1 = require("@player-tools/xlr-converters");
|
|
22
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
23
12
|
const base_command_1 = require("../../utils/base-command");
|
|
24
13
|
const visitors_1 = require("../../utils/xlr/visitors");
|
|
25
14
|
const consts_1 = require("../../utils/xlr/consts");
|
|
@@ -27,41 +16,36 @@ const consts_1 = require("../../utils/xlr/consts");
|
|
|
27
16
|
* Exports TS Interfaces/Types to XLR format
|
|
28
17
|
*/
|
|
29
18
|
class XLRCompile extends base_command_1.BaseCommand {
|
|
30
|
-
getOptions() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
async getOptions() {
|
|
20
|
+
const { flags } = await this.parse(XLRCompile);
|
|
21
|
+
const config = await this.getPlayerConfig();
|
|
22
|
+
const input = config.xlr?.input ?? flags.input;
|
|
23
|
+
const output = config.xlr?.output ?? flags.output;
|
|
24
|
+
const modeValue = config.xlr?.mode ?? flags.mode;
|
|
25
|
+
return {
|
|
26
|
+
inputPath: input,
|
|
27
|
+
outputDir: path_1.default.join(output, "xlr"),
|
|
28
|
+
mode: modeValue === "plugin" ? consts_1.Mode.PLUGIN : consts_1.Mode.TYPES,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async run() {
|
|
32
|
+
const { inputPath, outputDir, mode } = await this.getOptions();
|
|
33
|
+
const inputFiles = globby_1.default.sync([
|
|
34
|
+
`${inputPath}/**/*.ts`,
|
|
35
|
+
`${inputPath}/**/*.tsx`,
|
|
36
|
+
]);
|
|
37
|
+
try {
|
|
38
|
+
this.processTypes(inputFiles, outputDir, {}, mode);
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.log("");
|
|
42
|
+
console.log(chalk_1.default.red(`${log_symbols_1.default.error} Error compiling XLRs: ${e.message}`));
|
|
43
|
+
console.log(chalk_1.default.red(`${e.stack}`));
|
|
38
44
|
return {
|
|
39
|
-
|
|
40
|
-
outputDir: path_1.default.join(output, 'xlr'),
|
|
41
|
-
mode: modeValue === 'plugin' ? consts_1.Mode.PLUGIN : consts_1.Mode.TYPES,
|
|
45
|
+
exitCode: 1,
|
|
42
46
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
run() {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const { inputPath, outputDir, mode } = yield this.getOptions();
|
|
48
|
-
const inputFiles = globby_1.default.sync([
|
|
49
|
-
`${inputPath}/**/*.ts`,
|
|
50
|
-
`${inputPath}/**/*.tsx`,
|
|
51
|
-
]);
|
|
52
|
-
try {
|
|
53
|
-
this.processTypes(inputFiles, outputDir, {}, mode);
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
console.log('');
|
|
57
|
-
console.log(chalk_1.default.red(`${log_symbols_1.default.error} Error compiling XLRs: ${e.message}`));
|
|
58
|
-
console.log(chalk_1.default.red(`${e.stack}`));
|
|
59
|
-
return {
|
|
60
|
-
exitCode: 1,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return { exitCode: 0 };
|
|
64
|
-
});
|
|
47
|
+
}
|
|
48
|
+
return { exitCode: 0 };
|
|
65
49
|
}
|
|
66
50
|
/** Serializes ES6 Maps */
|
|
67
51
|
replacer(key, value) {
|
|
@@ -72,7 +56,6 @@ class XLRCompile extends base_command_1.BaseCommand {
|
|
|
72
56
|
}
|
|
73
57
|
/** Generate extension manifest/description files from an Enhanced Player Plugin */
|
|
74
58
|
processTypes(fileNames, outputDirectory, options, mode = consts_1.Mode.PLUGIN) {
|
|
75
|
-
var _a, _b, _c, _d, _e, _f;
|
|
76
59
|
// Build a program using the set of root file names in fileNames
|
|
77
60
|
const program = typescript_1.default.createProgram(fileNames, options);
|
|
78
61
|
fs_1.default.mkdirSync(outputDirectory, { recursive: true });
|
|
@@ -105,57 +88,68 @@ class XLRCompile extends base_command_1.BaseCommand {
|
|
|
105
88
|
throw new Error(`Error: Option ${mode} not recognized. Valid options are: plugin or type`);
|
|
106
89
|
}
|
|
107
90
|
if (generatedCapabilites) {
|
|
108
|
-
generatedCapabilites =
|
|
91
|
+
generatedCapabilites = {
|
|
92
|
+
...generatedCapabilites,
|
|
93
|
+
};
|
|
109
94
|
if (consts_1.customPrimitives) {
|
|
110
|
-
generatedCapabilites =
|
|
95
|
+
generatedCapabilites = {
|
|
96
|
+
...generatedCapabilites,
|
|
97
|
+
customPrimitives: consts_1.customPrimitives,
|
|
98
|
+
};
|
|
111
99
|
}
|
|
112
100
|
capabilities = generatedCapabilites;
|
|
113
101
|
}
|
|
114
102
|
}
|
|
115
103
|
});
|
|
116
104
|
if (!capabilities) {
|
|
117
|
-
throw new Error(
|
|
105
|
+
throw new Error("Error: Unable to parse any XLRs in package");
|
|
118
106
|
}
|
|
119
107
|
// print out the manifest files
|
|
120
108
|
const jsonManifest = JSON.stringify(capabilities, this.replacer, 4);
|
|
121
|
-
fs_1.default.writeFileSync(path_1.default.join(outputDirectory,
|
|
122
|
-
const tsManifestFile = `${[...(
|
|
109
|
+
fs_1.default.writeFileSync(path_1.default.join(outputDirectory, "manifest.json"), jsonManifest);
|
|
110
|
+
const tsManifestFile = `${[...(capabilities.capabilities?.values() ?? [])]
|
|
123
111
|
.flat(2)
|
|
124
112
|
.map((capability) => {
|
|
125
|
-
return `const ${capability} = require(
|
|
113
|
+
return `const ${capability} = require("./${capability}.json")`;
|
|
126
114
|
})
|
|
127
|
-
.join(
|
|
115
|
+
.join("\n")}
|
|
128
116
|
|
|
129
117
|
module.exports = {
|
|
130
118
|
"pluginName": "${capabilities.pluginName}",
|
|
131
119
|
"capabilities": {
|
|
132
|
-
${[...(
|
|
120
|
+
${[...(capabilities.capabilities?.entries() ?? [])]
|
|
133
121
|
.map(([capabilityName, provides]) => {
|
|
134
|
-
return `"${capabilityName}":[${provides.join(
|
|
122
|
+
return `"${capabilityName}":[${provides.join(",")}],`;
|
|
135
123
|
})
|
|
136
|
-
.join(
|
|
124
|
+
.join("\n\t\t")}
|
|
137
125
|
},
|
|
138
126
|
"customPrimitives": [
|
|
139
|
-
${[
|
|
127
|
+
${[capabilities.customPrimitives?.map((i) => `"${i}"`).join(",") ?? ""]}
|
|
140
128
|
]
|
|
141
129
|
}
|
|
142
130
|
`;
|
|
143
|
-
fs_1.default.writeFileSync(path_1.default.join(outputDirectory,
|
|
131
|
+
fs_1.default.writeFileSync(path_1.default.join(outputDirectory, "manifest.js"), tsManifestFile);
|
|
144
132
|
}
|
|
145
133
|
}
|
|
134
|
+
XLRCompile.description = "Compiles typescript files to XLRs format";
|
|
135
|
+
XLRCompile.flags = {
|
|
136
|
+
...base_command_1.BaseCommand.flags,
|
|
137
|
+
input: core_1.Flags.string({
|
|
138
|
+
char: "i",
|
|
139
|
+
description: "An input directory to search for types to export",
|
|
140
|
+
default: "./src",
|
|
141
|
+
}),
|
|
142
|
+
output: core_1.Flags.string({
|
|
143
|
+
char: "o",
|
|
144
|
+
description: "Output directory to write results to.",
|
|
145
|
+
default: "./dist",
|
|
146
|
+
}),
|
|
147
|
+
mode: core_1.Flags.enum({
|
|
148
|
+
char: "m",
|
|
149
|
+
description: "Search strategy for types to export: plugin (default, looks for exported EnchancedPlayerPlugin classes) or type (all exported types)",
|
|
150
|
+
options: ["plugin", "types"],
|
|
151
|
+
default: "plugin",
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
146
154
|
exports.default = XLRCompile;
|
|
147
|
-
|
|
148
|
-
XLRCompile.flags = Object.assign(Object.assign({}, base_command_1.BaseCommand.flags), { input: core_1.Flags.string({
|
|
149
|
-
char: 'i',
|
|
150
|
-
description: 'An input directory to search for types to export',
|
|
151
|
-
default: './src',
|
|
152
|
-
}), output: core_1.Flags.string({
|
|
153
|
-
char: 'o',
|
|
154
|
-
description: 'Output directory to write results to.',
|
|
155
|
-
default: './dist',
|
|
156
|
-
}), mode: core_1.Flags.enum({
|
|
157
|
-
char: 'm',
|
|
158
|
-
description: 'Search strategy for types to export: plugin (default, looks for exported EnchancedPlayerPlugin classes) or type (all exported types)',
|
|
159
|
-
options: ['plugin', 'types'],
|
|
160
|
-
default: 'plugin',
|
|
161
|
-
}) });
|
|
155
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -1,86 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
15
4
|
const core_1 = require("@oclif/core");
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const fs_1 = __importDefault(require("fs"));
|
|
18
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
19
8
|
const xlr_sdk_1 = require("@player-tools/xlr-sdk");
|
|
20
|
-
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
9
|
+
const log_symbols_1 = tslib_1.__importDefault(require("log-symbols"));
|
|
21
10
|
const base_command_1 = require("../../utils/base-command");
|
|
22
11
|
const PlayerImportMap = new Map([
|
|
23
12
|
[
|
|
24
|
-
|
|
25
|
-
[
|
|
13
|
+
"@player-ui/types",
|
|
14
|
+
["Expression", "Asset", "Binding", "AssetWrapper", "Schema.DataType"],
|
|
26
15
|
],
|
|
27
16
|
]);
|
|
28
17
|
/**
|
|
29
18
|
* Converts XLRs into a specific language
|
|
30
19
|
*/
|
|
31
20
|
class XLRConvert extends base_command_1.BaseCommand {
|
|
32
|
-
getOptions() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
});
|
|
21
|
+
async getOptions() {
|
|
22
|
+
const { flags } = await this.parse(XLRConvert);
|
|
23
|
+
const { input, output } = flags;
|
|
24
|
+
if (!output) {
|
|
25
|
+
throw new Error(`Need to specify location to export to`);
|
|
26
|
+
}
|
|
27
|
+
const language = flags.lang;
|
|
28
|
+
if (!language) {
|
|
29
|
+
throw new Error(`Need to specifiy lanauge to export to`);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
inputPath: input,
|
|
33
|
+
outputDir: path_1.default.join(output, language),
|
|
34
|
+
language,
|
|
35
|
+
};
|
|
49
36
|
}
|
|
50
|
-
run() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
56
|
-
}
|
|
57
|
-
const sdk = new xlr_sdk_1.XLRSDK();
|
|
58
|
-
sdk.loadDefinitionsFromDisk(inputPath);
|
|
59
|
-
const files = sdk.exportRegistry(language, PlayerImportMap);
|
|
60
|
-
files.forEach(([filename, fileContents]) => {
|
|
61
|
-
fs_1.default.writeFileSync(path_1.default.join(outputDir, filename), fileContents, {});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
console.log('');
|
|
66
|
-
console.log(chalk_1.default.red(`${log_symbols_1.default.error} Error exporting XLRs: ${e.message}`));
|
|
67
|
-
return { exitCode: 1 };
|
|
37
|
+
async run() {
|
|
38
|
+
const { inputPath, outputDir, language } = await this.getOptions();
|
|
39
|
+
try {
|
|
40
|
+
if (!fs_1.default.existsSync(outputDir)) {
|
|
41
|
+
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
68
42
|
}
|
|
69
|
-
|
|
70
|
-
|
|
43
|
+
const sdk = new xlr_sdk_1.XLRSDK();
|
|
44
|
+
sdk.loadDefinitionsFromDisk(inputPath);
|
|
45
|
+
const files = sdk.exportRegistry(language, PlayerImportMap);
|
|
46
|
+
files.forEach(([filename, fileContents]) => {
|
|
47
|
+
fs_1.default.writeFileSync(path_1.default.join(outputDir, filename), fileContents, {});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.log("");
|
|
52
|
+
console.log(chalk_1.default.red(`${log_symbols_1.default.error} Error exporting XLRs: ${e.message}`));
|
|
53
|
+
return { exitCode: 1 };
|
|
54
|
+
}
|
|
55
|
+
return { exitCode: 0 };
|
|
71
56
|
}
|
|
72
57
|
}
|
|
58
|
+
XLRConvert.description = "Exports XLRs files to a specific language";
|
|
59
|
+
XLRConvert.flags = {
|
|
60
|
+
...base_command_1.BaseCommand.flags,
|
|
61
|
+
input: core_1.Flags.string({
|
|
62
|
+
char: "i",
|
|
63
|
+
description: "An input directory to search for types to export",
|
|
64
|
+
default: "./dist",
|
|
65
|
+
}),
|
|
66
|
+
output: core_1.Flags.string({
|
|
67
|
+
char: "o",
|
|
68
|
+
description: "Output directory to write results to.",
|
|
69
|
+
}),
|
|
70
|
+
lang: core_1.Flags.enum({
|
|
71
|
+
char: "l",
|
|
72
|
+
description: "Search strategy for types to export: plugin (default, looks for exported EnchancedPlayerPlugin classes) or type (all exported types)",
|
|
73
|
+
options: ["TypeScript"],
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
73
76
|
exports.default = XLRConvert;
|
|
74
|
-
|
|
75
|
-
XLRConvert.flags = Object.assign(Object.assign({}, base_command_1.BaseCommand.flags), { input: core_1.Flags.string({
|
|
76
|
-
char: 'i',
|
|
77
|
-
description: 'An input directory to search for types to export',
|
|
78
|
-
default: './dist',
|
|
79
|
-
}), output: core_1.Flags.string({
|
|
80
|
-
char: 'o',
|
|
81
|
-
description: 'Output directory to write results to.',
|
|
82
|
-
}), lang: core_1.Flags.enum({
|
|
83
|
-
char: 'l',
|
|
84
|
-
description: 'Search strategy for types to export: plugin (default, looks for exported EnchancedPlayerPlugin classes) or type (all exported types)',
|
|
85
|
-
options: ['TypeScript'],
|
|
86
|
-
}) });
|
|
77
|
+
//# sourceMappingURL=convert.js.map
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlayerCLIPlugin } from
|
|
1
|
+
import type { PlayerCLIPlugin } from "./plugins";
|
|
2
2
|
export interface PlayerConfigFileShape {
|
|
3
3
|
/** A base config to inherit defaults from */
|
|
4
4
|
extends?: string | PlayerConfigFileShape;
|
|
@@ -29,7 +29,7 @@ export interface PlayerConfigResolvedShape {
|
|
|
29
29
|
/** Where to write the resulting files */
|
|
30
30
|
output?: string;
|
|
31
31
|
/** When converting to XLR, what strategy to use */
|
|
32
|
-
mode?:
|
|
32
|
+
mode?: "plugin" | "types";
|
|
33
33
|
};
|
|
34
34
|
/** Flattened list of plugins */
|
|
35
35
|
plugins: Array<PlayerCLIPlugin>;
|
package/dist/config.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { run } from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export { run } from "@oclif/core";
|
|
2
|
+
export * from "./config";
|
|
3
|
+
export * from "./plugins";
|
|
4
|
+
export * from "./utils/base-command";
|
|
5
|
+
export * from "./utils/compilation-context";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|