@player-cli/cli 0.0.2--canary.6.49
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 +82 -0
- package/bin/dev +17 -0
- package/bin/run +11 -0
- package/dist/commands/dependency-versions/check.d.ts +19 -0
- package/dist/commands/dependency-versions/check.js +270 -0
- package/dist/commands/dsl/compile.d.ts +20 -0
- package/dist/commands/dsl/compile.js +173 -0
- package/dist/commands/dsl/validate.d.ts +15 -0
- package/dist/commands/dsl/validate.js +142 -0
- package/dist/commands/json/validate.d.ts +18 -0
- package/dist/commands/json/validate.js +91 -0
- package/dist/commands/xlr/compile.d.ts +24 -0
- package/dist/commands/xlr/compile.js +153 -0
- package/dist/commands/xlr/convert.d.ts +20 -0
- package/dist/commands/xlr/convert.js +77 -0
- package/dist/config.d.ts +39 -0
- package/dist/config.js +3 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +12 -0
- package/dist/plugins/LSPAssetsPlugin.d.ts +50 -0
- package/dist/plugins/LSPAssetsPlugin.js +47 -0
- package/dist/plugins/LSPPluginPlugin.d.ts +11 -0
- package/dist/plugins/LSPPluginPlugin.js +22 -0
- package/dist/plugins/LSPTransformsPlugin.d.ts +12 -0
- package/dist/plugins/LSPTransformsPlugin.js +17 -0
- package/dist/plugins/index.d.ts +33 -0
- package/dist/plugins/index.js +7 -0
- package/dist/utils/babel-register.d.ts +3 -0
- package/dist/utils/babel-register.js +19 -0
- package/dist/utils/base-command.d.ts +26 -0
- package/dist/utils/base-command.js +155 -0
- package/dist/utils/compilation-context.d.ts +53 -0
- package/dist/utils/compilation-context.js +57 -0
- package/dist/utils/compile-renderer.d.ts +13 -0
- package/dist/utils/compile-renderer.js +42 -0
- package/dist/utils/compiler-options.d.ts +3 -0
- package/dist/utils/compiler-options.js +16 -0
- package/dist/utils/diag-renderer.d.ts +31 -0
- package/dist/utils/diag-renderer.js +224 -0
- package/dist/utils/fs.d.ts +9 -0
- package/dist/utils/fs.js +39 -0
- package/dist/utils/log-levels.d.ts +11 -0
- package/dist/utils/log-levels.js +21 -0
- package/dist/utils/task-runner.d.ts +59 -0
- package/dist/utils/task-runner.js +59 -0
- package/dist/utils/xlr/consts.d.ts +7 -0
- package/dist/utils/xlr/consts.js +18 -0
- package/dist/utils/xlr/visitors/file.d.ts +5 -0
- package/dist/utils/xlr/visitors/file.js +25 -0
- package/dist/utils/xlr/visitors/index.d.ts +4 -0
- package/dist/utils/xlr/visitors/index.js +7 -0
- package/dist/utils/xlr/visitors/plugin.d.ts +5 -0
- package/dist/utils/xlr/visitors/plugin.js +167 -0
- package/dist/utils/xlr/visitors/types.d.ts +13 -0
- package/dist/utils/xlr/visitors/types.js +3 -0
- package/package.json +58 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LSPAssetsPlugin = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Handles setting the assets when loading the LSP
|
|
6
|
+
*
|
|
7
|
+
* {
|
|
8
|
+
* "plugins": [
|
|
9
|
+
* [
|
|
10
|
+
* "@cli/lsp-assets-plugin",
|
|
11
|
+
* {
|
|
12
|
+
* "path": "<url> or <path>"
|
|
13
|
+
* }
|
|
14
|
+
* ]
|
|
15
|
+
* ]
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
class LSPAssetsPlugin {
|
|
20
|
+
config;
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.config = config;
|
|
23
|
+
}
|
|
24
|
+
async onCreateLanguageService(lsp, exp) {
|
|
25
|
+
if (Array.isArray(this.config)) {
|
|
26
|
+
await Promise.all(this.config.map((c) => {
|
|
27
|
+
this.loadConfig(c, lsp);
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
await this.loadConfig(this.config, lsp);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async loadConfig(config, lsp) {
|
|
35
|
+
if (config.type === "manifest" || config.type === undefined) {
|
|
36
|
+
await lsp.setAssetTypes([config.path]);
|
|
37
|
+
}
|
|
38
|
+
else if (config.type === "module") {
|
|
39
|
+
await lsp.setAssetTypesFromModule([config.manifest]);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw Error(`Unknown config type: ${config.type}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.LSPAssetsPlugin = LSPAssetsPlugin;
|
|
47
|
+
//# sourceMappingURL=LSPAssetsPlugin.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PlayerLanguageService, PlayerLanguageServicePlugin } from "@player-tools/json-language-service";
|
|
2
|
+
import type { PlayerCLIPlugin } from "./index";
|
|
3
|
+
/**
|
|
4
|
+
* Handles adding a LSP Plugin to the LSP
|
|
5
|
+
*/
|
|
6
|
+
export declare class LSPPluginPlugin implements PlayerCLIPlugin {
|
|
7
|
+
private plugin;
|
|
8
|
+
constructor(plugin: PlayerLanguageServicePlugin | Array<PlayerLanguageServicePlugin>);
|
|
9
|
+
onCreateLanguageService(lsp: PlayerLanguageService, exp: boolean): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=LSPPluginPlugin.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LSPPluginPlugin = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Handles adding a LSP Plugin to the LSP
|
|
6
|
+
*/
|
|
7
|
+
class LSPPluginPlugin {
|
|
8
|
+
plugin;
|
|
9
|
+
constructor(plugin) {
|
|
10
|
+
this.plugin = plugin;
|
|
11
|
+
}
|
|
12
|
+
async onCreateLanguageService(lsp, exp) {
|
|
13
|
+
if (Array.isArray(this.plugin)) {
|
|
14
|
+
this.plugin.forEach((p) => lsp.addLSPPlugin(p));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
lsp.addLSPPlugin(this.plugin);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.LSPPluginPlugin = LSPPluginPlugin;
|
|
22
|
+
//# sourceMappingURL=LSPPluginPlugin.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PlayerLanguageService } from "@player-tools/json-language-service";
|
|
2
|
+
import type { TransformFunction } from "@player-tools/xlr";
|
|
3
|
+
import type { PlayerCLIPlugin } from "./index";
|
|
4
|
+
/**
|
|
5
|
+
* Handles adding XLR transforms to the LSP's XLR SDK
|
|
6
|
+
*/
|
|
7
|
+
export declare class LSPTransformsPlugin implements PlayerCLIPlugin {
|
|
8
|
+
private functionsToLoad;
|
|
9
|
+
constructor(functionsToLoad: Record<string, TransformFunction>);
|
|
10
|
+
onCreateLanguageService(lsp: PlayerLanguageService, exp: boolean): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=LSPTransformsPlugin.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LSPTransformsPlugin = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Handles adding XLR transforms to the LSP's XLR SDK
|
|
6
|
+
*/
|
|
7
|
+
class LSPTransformsPlugin {
|
|
8
|
+
functionsToLoad;
|
|
9
|
+
constructor(functionsToLoad) {
|
|
10
|
+
this.functionsToLoad = functionsToLoad;
|
|
11
|
+
}
|
|
12
|
+
async onCreateLanguageService(lsp, exp) {
|
|
13
|
+
lsp.addXLRTransforms(this.functionsToLoad);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.LSPTransformsPlugin = LSPTransformsPlugin;
|
|
17
|
+
//# sourceMappingURL=LSPTransformsPlugin.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PlayerLanguageService } from "@player-tools/json-language-service";
|
|
2
|
+
import type { DSLCompiler } from "@player-tools/dsl";
|
|
3
|
+
import type { ExportTypes } from "@player-tools/xlr-sdk";
|
|
4
|
+
import type { TransformFunction } from "@player-tools/xlr";
|
|
5
|
+
import type { CompilationContext } from "../utils/compilation-context";
|
|
6
|
+
export * from "./LSPAssetsPlugin";
|
|
7
|
+
export * from "./LSPPluginPlugin";
|
|
8
|
+
export * from "./LSPTransformsPlugin";
|
|
9
|
+
export interface PlayerCLIPlugin {
|
|
10
|
+
/**
|
|
11
|
+
* Handler when an LSP instance is created
|
|
12
|
+
* Use this to add custom rule-sets, load asset types, etc
|
|
13
|
+
*/
|
|
14
|
+
onCreateLanguageService?: (lsp: PlayerLanguageService, exp: boolean) => void | Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Handler when a DSL compiler is created
|
|
17
|
+
* Use this to change how content is generated
|
|
18
|
+
*/
|
|
19
|
+
onCreateDSLCompiler?: (compiler: DSLCompiler) => void | Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Handler for when context is being converted from XLRs to a language specific representation
|
|
22
|
+
* Append the transforms to apply to the passed in array based on the provided format
|
|
23
|
+
*/
|
|
24
|
+
onConvertXLR?: (format: ExportTypes, transforms: Array<TransformFunction>) => void | Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Handler to expose hooks that influence how content is compiled
|
|
27
|
+
*/
|
|
28
|
+
createCompilerContext?: (context: CompilationContext) => void | Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export type PlayerCLIClass = {
|
|
31
|
+
new (): PlayerCLIPlugin;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./LSPAssetsPlugin"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./LSPPluginPlugin"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./LSPTransformsPlugin"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerForPaths = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const register_1 = tslib_1.__importDefault(require("@babel/register"));
|
|
6
|
+
/** Register a `require()` loader for any of the given paths */
|
|
7
|
+
const registerForPaths = () => {
|
|
8
|
+
(0, register_1.default)({
|
|
9
|
+
extensions: [".es6", ".es", ".jsx", ".js", ".mjs", ".tsx", ".ts"],
|
|
10
|
+
presets: [
|
|
11
|
+
[require.resolve("@babel/preset-env"), { modules: "cjs" }],
|
|
12
|
+
require.resolve("@babel/preset-typescript"),
|
|
13
|
+
require.resolve("@babel/preset-react"),
|
|
14
|
+
],
|
|
15
|
+
plugins: [require.resolve("@babel/plugin-transform-react-jsx-source")],
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.registerForPaths = registerForPaths;
|
|
19
|
+
//# sourceMappingURL=babel-register.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { PlayerLanguageService } from "@player-tools/json-language-service";
|
|
3
|
+
import { DSLCompiler } from "@player-tools/dsl";
|
|
4
|
+
import type { ExportTypes } from "@player-tools/xlr-sdk";
|
|
5
|
+
import type { TransformFunction } from "@player-tools/xlr";
|
|
6
|
+
import type { PlayerConfigResolvedShape } from "../config";
|
|
7
|
+
import { CompilationContext } from "./compilation-context";
|
|
8
|
+
/** The common configs for all */
|
|
9
|
+
export declare abstract class BaseCommand extends Command {
|
|
10
|
+
static flags: {
|
|
11
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
12
|
+
loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
13
|
+
};
|
|
14
|
+
static strict: boolean;
|
|
15
|
+
private resolvedConfig;
|
|
16
|
+
private loadConfig;
|
|
17
|
+
private resolveConfig;
|
|
18
|
+
private readConfig;
|
|
19
|
+
protected getPlayerConfig(): Promise<PlayerConfigResolvedShape>;
|
|
20
|
+
createLanguageService(exp: boolean): Promise<PlayerLanguageService>;
|
|
21
|
+
createDSLCompiler(): Promise<DSLCompiler>;
|
|
22
|
+
getXLRTransforms(format: ExportTypes): Promise<Array<TransformFunction>>;
|
|
23
|
+
createCompilerContext(): Promise<CompilationContext>;
|
|
24
|
+
exit(code?: number): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=base-command.d.ts.map
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const cosmiconfig_1 = require("cosmiconfig");
|
|
8
|
+
const json_language_service_1 = require("@player-tools/json-language-service");
|
|
9
|
+
const dsl_1 = require("@player-tools/dsl");
|
|
10
|
+
const compilation_context_1 = require("./compilation-context");
|
|
11
|
+
const log_levels_1 = require("./log-levels");
|
|
12
|
+
const configLoader = (0, cosmiconfig_1.cosmiconfig)("player");
|
|
13
|
+
/** The common configs for all */
|
|
14
|
+
class BaseCommand extends core_1.Command {
|
|
15
|
+
static flags = {
|
|
16
|
+
config: core_1.Flags.string({
|
|
17
|
+
description: "Path to a specific config file to load.\nBy default, will automatically search for an rc or config file to load",
|
|
18
|
+
char: "c",
|
|
19
|
+
}),
|
|
20
|
+
loglevel: core_1.Flags.string({
|
|
21
|
+
char: "v",
|
|
22
|
+
description: "How verbose logs should be",
|
|
23
|
+
options: log_levels_1.LogLevels,
|
|
24
|
+
default: "warn",
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
static strict = false;
|
|
28
|
+
resolvedConfig;
|
|
29
|
+
async loadConfig(configFilePath) {
|
|
30
|
+
if (configFilePath) {
|
|
31
|
+
try {
|
|
32
|
+
return await configLoader.load(configFilePath);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
this.warn(`Error loading config file: ${configFilePath}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return configLoader.search();
|
|
39
|
+
}
|
|
40
|
+
async resolveConfig(conf, relativePath) {
|
|
41
|
+
let config = {
|
|
42
|
+
...(conf ?? {}),
|
|
43
|
+
plugins: [],
|
|
44
|
+
};
|
|
45
|
+
// If there's an extension load it
|
|
46
|
+
if (conf?.extends) {
|
|
47
|
+
let normalizedExtension;
|
|
48
|
+
if (typeof conf.extends === "string") {
|
|
49
|
+
const requiredExtendedConfig = await Promise.resolve(`${conf.extends}`).then(s => tslib_1.__importStar(require(s)));
|
|
50
|
+
normalizedExtension =
|
|
51
|
+
requiredExtendedConfig.default ?? requiredExtendedConfig;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
normalizedExtension = conf.extends;
|
|
55
|
+
}
|
|
56
|
+
config = {
|
|
57
|
+
...(await this.resolveConfig(normalizedExtension, relativePath)),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
await Promise.all(conf?.presets?.map(async (preset) => {
|
|
61
|
+
if (typeof preset === "string") {
|
|
62
|
+
const requiredExtendedConfig = await Promise.resolve(`${preset}`).then(s => tslib_1.__importStar(require(s)));
|
|
63
|
+
const normalizedExtension = requiredExtendedConfig.default ?? requiredExtendedConfig;
|
|
64
|
+
const extendedConfig = await this.resolveConfig(normalizedExtension);
|
|
65
|
+
config.plugins = [...extendedConfig.plugins, ...config.plugins];
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const presetConfig = await this.resolveConfig(preset);
|
|
69
|
+
config.plugins = [...presetConfig.plugins, ...config.plugins];
|
|
70
|
+
}) ?? []);
|
|
71
|
+
// Go through each plugin and load/create it
|
|
72
|
+
if (conf?.plugins) {
|
|
73
|
+
await Promise.all(conf?.plugins?.map(async (pluginInfo) => {
|
|
74
|
+
if (typeof pluginInfo === "object" && !Array.isArray(pluginInfo)) {
|
|
75
|
+
config.plugins.push(pluginInfo);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const pluginName = typeof pluginInfo === "string" ? pluginInfo : pluginInfo[0];
|
|
79
|
+
const pluginArgs = typeof pluginInfo === "string" ? undefined : pluginInfo[1];
|
|
80
|
+
let pluginLoadPath = pluginName;
|
|
81
|
+
if (pluginName.startsWith(".")) {
|
|
82
|
+
pluginLoadPath = path_1.default.resolve(relativePath ?? "", pluginName);
|
|
83
|
+
}
|
|
84
|
+
this.debug("loading plugin from %s", pluginLoadPath);
|
|
85
|
+
// Get the instance for the plugin
|
|
86
|
+
const required = await Promise.resolve(`${pluginLoadPath}`).then(s => tslib_1.__importStar(require(s)));
|
|
87
|
+
const PluginExport = required.default ?? required;
|
|
88
|
+
if (!PluginExport) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const pluginInstance = typeof PluginExport === "object"
|
|
92
|
+
? PluginExport
|
|
93
|
+
: new PluginExport(pluginArgs);
|
|
94
|
+
config.plugins.push(pluginInstance);
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
return config;
|
|
98
|
+
}
|
|
99
|
+
async readConfig() {
|
|
100
|
+
const { flags } = await this.parse(BaseCommand);
|
|
101
|
+
const configFile = await this.loadConfig(flags.config);
|
|
102
|
+
return this.resolveConfig(configFile?.config);
|
|
103
|
+
}
|
|
104
|
+
async getPlayerConfig() {
|
|
105
|
+
if (this.resolvedConfig) {
|
|
106
|
+
return this.resolvedConfig;
|
|
107
|
+
}
|
|
108
|
+
const c = await this.readConfig();
|
|
109
|
+
this.resolvedConfig = c;
|
|
110
|
+
return c;
|
|
111
|
+
}
|
|
112
|
+
async createLanguageService(exp) {
|
|
113
|
+
const lsp = new json_language_service_1.PlayerLanguageService();
|
|
114
|
+
const { plugins } = await this.getPlayerConfig();
|
|
115
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
116
|
+
await plugins[i].onCreateLanguageService?.(lsp, exp);
|
|
117
|
+
}
|
|
118
|
+
return lsp;
|
|
119
|
+
}
|
|
120
|
+
async createDSLCompiler() {
|
|
121
|
+
const compiler = new dsl_1.DSLCompiler({
|
|
122
|
+
error: this.error.bind(this),
|
|
123
|
+
warn: this.warn.bind(this),
|
|
124
|
+
log: this.log.bind(this),
|
|
125
|
+
});
|
|
126
|
+
const { plugins } = await this.getPlayerConfig();
|
|
127
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
128
|
+
await plugins[i].onCreateDSLCompiler?.(compiler);
|
|
129
|
+
}
|
|
130
|
+
return compiler;
|
|
131
|
+
}
|
|
132
|
+
async getXLRTransforms(format) {
|
|
133
|
+
const transforms = [];
|
|
134
|
+
const { plugins } = await this.getPlayerConfig();
|
|
135
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
136
|
+
await plugins[i].onConvertXLR?.(format, transforms);
|
|
137
|
+
}
|
|
138
|
+
return transforms;
|
|
139
|
+
}
|
|
140
|
+
async createCompilerContext() {
|
|
141
|
+
const compilerContext = new compilation_context_1.CompilationContext(await this.createDSLCompiler());
|
|
142
|
+
const { plugins } = await this.getPlayerConfig();
|
|
143
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
144
|
+
await plugins[i].createCompilerContext?.(compilerContext);
|
|
145
|
+
}
|
|
146
|
+
return compilerContext;
|
|
147
|
+
}
|
|
148
|
+
exit(code) {
|
|
149
|
+
if (process.env.NODE_ENV !== "test") {
|
|
150
|
+
super.exit(code);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.BaseCommand = BaseCommand;
|
|
155
|
+
//# sourceMappingURL=base-command.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { DSLCompiler, SerializeContext } from "@player-tools/dsl";
|
|
2
|
+
import { AsyncSeriesBailHook } from "tapable-ts";
|
|
3
|
+
export interface identifyContentReturn {
|
|
4
|
+
/** The identified type the content should be compiled as */
|
|
5
|
+
type: string;
|
|
6
|
+
/** The file extension the content should be written as */
|
|
7
|
+
extension: string;
|
|
8
|
+
}
|
|
9
|
+
export interface compileContentArgs extends Omit<SerializeContext, "type"> {
|
|
10
|
+
type: string;
|
|
11
|
+
}
|
|
12
|
+
export interface compilationResult {
|
|
13
|
+
/** the JSON value of the source */
|
|
14
|
+
value: string;
|
|
15
|
+
/** The sourcemap of the content */
|
|
16
|
+
sourceMap?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare class CompilationContext {
|
|
22
|
+
/** Hooks to wrap the context of the compilation */
|
|
23
|
+
hooks: {
|
|
24
|
+
/**
|
|
25
|
+
* Function for determining a specific or desired content type given on the file contents or other conditions
|
|
26
|
+
*
|
|
27
|
+
* @param fileName - The relative name of the file
|
|
28
|
+
* @param content - The contents in the file
|
|
29
|
+
* @returns content type and extension
|
|
30
|
+
*/
|
|
31
|
+
identifyContentType: AsyncSeriesBailHook<[string, any], identifyContentReturn, Record<string, any>>;
|
|
32
|
+
/**
|
|
33
|
+
* Function for returning the compile content given an specific type or condition
|
|
34
|
+
*
|
|
35
|
+
* @param context - Settings for the content to be compiled, such as type
|
|
36
|
+
* @param content - The contents in the file
|
|
37
|
+
* @param fileName - The relative name of the file
|
|
38
|
+
* @returns CompilerReturn object instance or undefined
|
|
39
|
+
*/
|
|
40
|
+
compileContent: AsyncSeriesBailHook<[compileContentArgs, any, string], compilationResult, Record<string, any>>;
|
|
41
|
+
/**
|
|
42
|
+
* Function for determining if a file should be skipped during compilation
|
|
43
|
+
*
|
|
44
|
+
* @param fileName - The relative name of the file
|
|
45
|
+
* @returns true if the file should be skipped, false or undefined otherwise
|
|
46
|
+
*/
|
|
47
|
+
skipCompilation: AsyncSeriesBailHook<[string], boolean, Record<string, any>>;
|
|
48
|
+
};
|
|
49
|
+
/** A DSL compiler instance */
|
|
50
|
+
dslCompiler: DSLCompiler;
|
|
51
|
+
constructor(dslCompiler: DSLCompiler);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=compilation-context.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompilationContext = void 0;
|
|
4
|
+
const dsl_1 = require("@player-tools/dsl");
|
|
5
|
+
const tapable_ts_1 = require("tapable-ts");
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
class CompilationContext {
|
|
10
|
+
/** Hooks to wrap the context of the compilation */
|
|
11
|
+
hooks = {
|
|
12
|
+
/**
|
|
13
|
+
* Function for determining a specific or desired content type given on the file contents or other conditions
|
|
14
|
+
*
|
|
15
|
+
* @param fileName - The relative name of the file
|
|
16
|
+
* @param content - The contents in the file
|
|
17
|
+
* @returns content type and extension
|
|
18
|
+
*/
|
|
19
|
+
identifyContentType: new tapable_ts_1.AsyncSeriesBailHook(),
|
|
20
|
+
/**
|
|
21
|
+
* Function for returning the compile content given an specific type or condition
|
|
22
|
+
*
|
|
23
|
+
* @param context - Settings for the content to be compiled, such as type
|
|
24
|
+
* @param content - The contents in the file
|
|
25
|
+
* @param fileName - The relative name of the file
|
|
26
|
+
* @returns CompilerReturn object instance or undefined
|
|
27
|
+
*/
|
|
28
|
+
compileContent: new tapable_ts_1.AsyncSeriesBailHook(),
|
|
29
|
+
/**
|
|
30
|
+
* Function for determining if a file should be skipped during compilation
|
|
31
|
+
*
|
|
32
|
+
* @param fileName - The relative name of the file
|
|
33
|
+
* @returns true if the file should be skipped, false or undefined otherwise
|
|
34
|
+
*/
|
|
35
|
+
skipCompilation: new tapable_ts_1.AsyncSeriesBailHook(),
|
|
36
|
+
};
|
|
37
|
+
/** A DSL compiler instance */
|
|
38
|
+
dslCompiler;
|
|
39
|
+
constructor(dslCompiler) {
|
|
40
|
+
this.dslCompiler = dslCompiler;
|
|
41
|
+
this.hooks.compileContent.tap("default", async ({ type }, content) => {
|
|
42
|
+
if ((0, dsl_1.isDefaultCompilerContentType)(type)) {
|
|
43
|
+
const compilationResults = await this.dslCompiler.serialize(content, {
|
|
44
|
+
type,
|
|
45
|
+
});
|
|
46
|
+
if (compilationResults) {
|
|
47
|
+
return {
|
|
48
|
+
value: JSON.stringify(compilationResults.value, null, 2),
|
|
49
|
+
sourceMap: compilationResults.sourceMap,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CompilationContext = CompilationContext;
|
|
57
|
+
//# sourceMappingURL=compilation-context.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SerializeType } from "@player-tools/dsl";
|
|
2
|
+
import type { TaskProgressRenderer } from "./task-runner";
|
|
3
|
+
export interface DSLCompileFileData {
|
|
4
|
+
/** the file name */
|
|
5
|
+
file: string;
|
|
6
|
+
/** the name of the output file */
|
|
7
|
+
outputFile?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const compileRenderer: TaskProgressRenderer<{
|
|
10
|
+
/** the type of content generated */
|
|
11
|
+
contentType: SerializeType;
|
|
12
|
+
} | undefined, DSLCompileFileData>;
|
|
13
|
+
//# sourceMappingURL=compile-renderer.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileRenderer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const figures_1 = tslib_1.__importDefault(require("figures"));
|
|
7
|
+
const diag_renderer_1 = require("./diag-renderer");
|
|
8
|
+
exports.compileRenderer = {
|
|
9
|
+
onUpdate: (ctx) => {
|
|
10
|
+
const output = [""];
|
|
11
|
+
ctx.tasks.forEach((task) => {
|
|
12
|
+
const outputType = task.state === "completed" && task.output?.contentType
|
|
13
|
+
? task.output.contentType
|
|
14
|
+
: undefined;
|
|
15
|
+
let titleLine = [
|
|
16
|
+
(0, diag_renderer_1.getTaskSymbol)(task),
|
|
17
|
+
outputType && `(${outputType})`,
|
|
18
|
+
task.data?.file,
|
|
19
|
+
]
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.join(" ");
|
|
22
|
+
if (task.data?.outputFile) {
|
|
23
|
+
titleLine = [
|
|
24
|
+
titleLine,
|
|
25
|
+
figures_1.default.arrowRight,
|
|
26
|
+
task.data.outputFile,
|
|
27
|
+
].join(" ");
|
|
28
|
+
}
|
|
29
|
+
output.push(titleLine);
|
|
30
|
+
if (task.state === "completed") {
|
|
31
|
+
if (task.error) {
|
|
32
|
+
output.push(` ${figures_1.default.arrowRight} ${chalk_1.default.red("bad")}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return output.join("\n");
|
|
37
|
+
},
|
|
38
|
+
onEnd: (ctx) => {
|
|
39
|
+
return [exports.compileRenderer.onUpdate(ctx)].join("\n");
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=compile-renderer.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_COMPILER_OPTIONS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
|
+
exports.DEFAULT_COMPILER_OPTIONS = {
|
|
7
|
+
strict: true,
|
|
8
|
+
target: typescript_1.default.ScriptTarget.ES2016,
|
|
9
|
+
allowJs: false,
|
|
10
|
+
jsx: typescript_1.default.JsxEmit.ReactJSX,
|
|
11
|
+
moduleResolution: typescript_1.default.ModuleResolutionKind.NodeJs,
|
|
12
|
+
allowSyntheticDefaultImports: true,
|
|
13
|
+
module: typescript_1.default.ModuleKind.ES2015,
|
|
14
|
+
skipLibCheck: true,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=compiler-options.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Diagnostic } from "vscode-languageserver-types";
|
|
2
|
+
import { DiagnosticSeverity } from "vscode-languageserver-types";
|
|
3
|
+
import type { Task, TaskProgressRenderer } from "./task-runner";
|
|
4
|
+
/** Get the lines representing the summary of the results */
|
|
5
|
+
export declare function getSummary({ errors, warnings, skipped, fileCount, duration, }: {
|
|
6
|
+
/** Error count */
|
|
7
|
+
errors: number;
|
|
8
|
+
/** Warning count */
|
|
9
|
+
warnings: number;
|
|
10
|
+
/** number of skipped files */
|
|
11
|
+
skipped?: number;
|
|
12
|
+
/** File Count */
|
|
13
|
+
fileCount: number;
|
|
14
|
+
/** How long this took */
|
|
15
|
+
duration: number | undefined;
|
|
16
|
+
}): string;
|
|
17
|
+
/** Format the results for printing on the console */
|
|
18
|
+
export declare function formatDiagnosticResults(filePath: string, results: Diagnostic[], loglevel: DiagnosticSeverity): {
|
|
19
|
+
lines: string[];
|
|
20
|
+
errors: number;
|
|
21
|
+
warnings: number;
|
|
22
|
+
info: number;
|
|
23
|
+
trace: number;
|
|
24
|
+
};
|
|
25
|
+
/** Get the symbol for a given task */
|
|
26
|
+
export declare const getTaskSymbol: (task: Task<any, any>) => string;
|
|
27
|
+
export declare const validationRenderer: TaskProgressRenderer<Diagnostic[], {
|
|
28
|
+
/** the file name */
|
|
29
|
+
file: string;
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=diag-renderer.d.ts.map
|