@useparagon/cli 0.0.1-canary.39 → 0.0.1-canary.4
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/apis/api.types.d.ts +8 -71
- package/dist/apis/auth.api.js +7 -5
- package/dist/apis/auth.api.js.map +1 -1
- package/dist/apis/base.api.d.ts +0 -3
- package/dist/apis/base.api.js +52 -51
- package/dist/apis/base.api.js.map +1 -1
- package/dist/apis/event.api.d.ts +2 -0
- package/dist/apis/event.api.js +10 -0
- package/dist/apis/event.api.js.map +1 -0
- package/dist/apis/index.d.ts +2 -0
- package/dist/apis/index.js +2 -0
- package/dist/apis/index.js.map +1 -1
- package/dist/apis/integration.api.d.ts +3 -3
- package/dist/apis/integration.api.js +10 -18
- package/dist/apis/integration.api.js.map +1 -1
- package/dist/apis/project.api.d.ts +1 -1
- package/dist/apis/project.api.js +17 -40
- package/dist/apis/project.api.js.map +1 -1
- package/dist/apis/workflow.api.d.ts +2 -0
- package/dist/apis/workflow.api.js +10 -0
- package/dist/apis/workflow.api.js.map +1 -0
- package/dist/codegen/codegen.types.d.ts +4 -12
- package/dist/codegen/codegen.utils.d.ts +1 -2
- package/dist/codegen/codegen.utils.js +28 -63
- package/dist/codegen/codegen.utils.js.map +1 -1
- package/dist/codegen/codegens/condition.codegen.js +35 -38
- package/dist/codegen/codegens/condition.codegen.js.map +1 -1
- package/dist/codegen/codegens/event.codegen.js +3 -4
- package/dist/codegen/codegens/event.codegen.js.map +1 -1
- package/dist/codegen/codegens/integration.codegen.d.ts +3 -3
- package/dist/codegen/codegens/integration.codegen.js +32 -138
- package/dist/codegen/codegens/integration.codegen.js.map +1 -1
- package/dist/codegen/codegens/source.codegen.d.ts +1 -3
- package/dist/codegen/codegens/source.codegen.js +31 -120
- package/dist/codegen/codegens/source.codegen.js.map +1 -1
- package/dist/codegen/codegens/workflow.codegen.js +111 -253
- package/dist/codegen/codegens/workflow.codegen.js.map +1 -1
- package/dist/commands/auth/login/login.action.js +31 -28
- package/dist/commands/auth/login/login.action.js.map +1 -1
- package/dist/commands/auth/login/login.command.js +4 -5
- package/dist/commands/auth/login/login.command.js.map +1 -1
- package/dist/commands/auth/login/login.utils.js +19 -26
- package/dist/commands/auth/login/login.utils.js.map +1 -1
- package/dist/commands/auth/logout/logout.action.js +5 -3
- package/dist/commands/auth/logout/logout.action.js.map +1 -1
- package/dist/commands/auth/logout/logout.command.js +3 -3
- package/dist/commands/auth/logout/logout.command.js.map +1 -1
- package/dist/commands/auth/me/me.action.js +6 -10
- package/dist/commands/auth/me/me.action.js.map +1 -1
- package/dist/commands/auth/me/me.command.js +3 -3
- package/dist/commands/auth/me/me.command.js.map +1 -1
- package/dist/commands/build/build.action.js +27 -27
- package/dist/commands/build/build.action.js.map +1 -1
- package/dist/commands/build/build.command.js +5 -9
- package/dist/commands/build/build.command.js.map +1 -1
- package/dist/commands/build/build.types.d.ts +0 -1
- package/dist/commands/build/build.utils.d.ts +1 -1
- package/dist/commands/build/build.utils.js +9 -11
- package/dist/commands/build/build.utils.js.map +1 -1
- package/dist/commands/command.loader.js +8 -10
- package/dist/commands/command.loader.js.map +1 -1
- package/dist/commands/init/init.action.d.ts +1 -1
- package/dist/commands/init/init.action.js +68 -93
- package/dist/commands/init/init.action.js.map +1 -1
- package/dist/commands/init/init.command.js +8 -14
- package/dist/commands/init/init.command.js.map +1 -1
- package/dist/commands/init/init.constants.js +23 -0
- package/dist/commands/init/init.constants.js.map +1 -0
- package/dist/commands/init/init.types.d.ts +0 -1
- package/dist/commands/init/init.utils.d.ts +11 -0
- package/dist/commands/init/init.utils.js +50 -0
- package/dist/commands/init/init.utils.js.map +1 -0
- package/dist/commands/push/push.action.js +11 -9
- package/dist/commands/push/push.action.js.map +1 -1
- package/dist/commands/push/push.command.js +4 -4
- package/dist/commands/push/push.command.js.map +1 -1
- package/dist/compiler/compiler.types.d.ts +2 -3
- package/dist/compiler/compiler.utils.d.ts +1 -1
- package/dist/compiler/compiler.utils.js +4 -8
- package/dist/compiler/compiler.utils.js.map +1 -1
- package/dist/compiler/compilers/events.compiler.js +28 -24
- package/dist/compiler/compilers/events.compiler.js.map +1 -1
- package/dist/compiler/compilers/integrations.compiler.js +52 -148
- package/dist/compiler/compilers/integrations.compiler.js.map +1 -1
- package/dist/compiler/compilers/persona.compiler.js +11 -4
- package/dist/compiler/compilers/persona.compiler.js.map +1 -1
- package/dist/compiler/compilers/project.compiler.d.ts +0 -1
- package/dist/compiler/compilers/project.compiler.js +23 -49
- package/dist/compiler/compilers/project.compiler.js.map +1 -1
- package/dist/compiler/compilers/workflows.compiler.js +33 -46
- package/dist/compiler/compilers/workflows.compiler.js.map +1 -1
- package/dist/compiler/ts.compiler.d.ts +3 -1
- package/dist/compiler/ts.compiler.js +18 -18
- package/dist/compiler/ts.compiler.js.map +1 -1
- package/dist/config/config.constants.d.ts +0 -1
- package/dist/config/config.constants.js +1 -2
- package/dist/config/config.constants.js.map +1 -1
- package/dist/config/config.types.d.ts +0 -4
- package/dist/config/config.utils.d.ts +3 -4
- package/dist/config/config.utils.js +37 -65
- package/dist/config/config.utils.js.map +1 -1
- package/dist/helpers/constants.d.ts +0 -1
- package/dist/helpers/constants.js +1 -2
- package/dist/helpers/constants.js.map +1 -1
- package/dist/helpers/file.d.ts +1 -3
- package/dist/helpers/file.js +15 -44
- package/dist/helpers/file.js.map +1 -1
- package/dist/helpers/strings.d.ts +0 -1
- package/dist/helpers/strings.js +1 -34
- package/dist/helpers/strings.js.map +1 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +1 -1
- package/dist/logger/logger.js +1 -5
- package/dist/logger/logger.js.map +1 -1
- package/dist/templates/configurations/typescript/tsconfig.json +2 -3
- package/dist/templates/javascript/src/events/hello-world.js +13 -0
- package/dist/templates/javascript/src/integrations/slack/config.js +11 -0
- package/dist/templates/javascript/src/integrations/slack/workflows/example-workflow.js +30 -0
- package/dist/templates/typescript/src/events/hello-world.ts +21 -0
- package/dist/templates/typescript/src/integrations/slack/config.ts +18 -0
- package/dist/templates/typescript/src/integrations/slack/workflows/example-workflow.ts +30 -0
- package/dist/templates/typescript/tsconfig.json +31 -0
- package/package.json +16 -20
- package/dist/codegen/codegens/intent.codegen.d.ts +0 -5
- package/dist/codegen/codegens/intent.codegen.js +0 -179
- package/dist/codegen/codegens/intent.codegen.js.map +0 -1
- package/dist/commands/install/index.d.ts +0 -1
- package/dist/commands/install/index.js +0 -5
- package/dist/commands/install/index.js.map +0 -1
- package/dist/commands/install/install.action.d.ts +0 -5
- package/dist/commands/install/install.action.js +0 -15
- package/dist/commands/install/install.action.js.map +0 -1
- package/dist/commands/install/install.command.d.ts +0 -8
- package/dist/commands/install/install.command.js +0 -24
- package/dist/commands/install/install.command.js.map +0 -1
- package/dist/commands/install/install.constants.js +0 -68
- package/dist/commands/install/install.constants.js.map +0 -1
- package/dist/commands/install/install.types.d.ts +0 -7
- package/dist/commands/install/install.types.js +0 -3
- package/dist/commands/install/install.types.js.map +0 -1
- package/dist/commands/install/install.utils.d.ts +0 -8
- package/dist/commands/install/install.utils.js +0 -130
- package/dist/commands/install/install.utils.js.map +0 -1
- package/dist/commands/new/index.d.ts +0 -1
- package/dist/commands/new/index.js +0 -5
- package/dist/commands/new/index.js.map +0 -1
- package/dist/commands/new/integration/index.d.ts +0 -1
- package/dist/commands/new/integration/index.js +0 -5
- package/dist/commands/new/integration/index.js.map +0 -1
- package/dist/commands/new/integration/integration.action.d.ts +0 -5
- package/dist/commands/new/integration/integration.action.js +0 -52
- package/dist/commands/new/integration/integration.action.js.map +0 -1
- package/dist/commands/new/integration/integration.command.d.ts +0 -8
- package/dist/commands/new/integration/integration.command.js +0 -26
- package/dist/commands/new/integration/integration.command.js.map +0 -1
- package/dist/commands/new/integration/integration.types.d.ts +0 -1
- package/dist/commands/new/integration/integration.types.js +0 -3
- package/dist/commands/new/integration/integration.types.js.map +0 -1
- package/dist/commands/new/new.command.d.ts +0 -5
- package/dist/commands/new/new.command.js +0 -16
- package/dist/commands/new/new.command.js.map +0 -1
- package/dist/commands/new/new.utils.d.ts +0 -1
- package/dist/commands/new/new.utils.js +0 -18
- package/dist/commands/new/new.utils.js.map +0 -1
- package/dist/commands/new/workflow/index.d.ts +0 -1
- package/dist/commands/new/workflow/index.js +0 -5
- package/dist/commands/new/workflow/index.js.map +0 -1
- package/dist/commands/new/workflow/workflow.action.d.ts +0 -5
- package/dist/commands/new/workflow/workflow.action.js +0 -94
- package/dist/commands/new/workflow/workflow.action.js.map +0 -1
- package/dist/commands/new/workflow/workflow.command.d.ts +0 -8
- package/dist/commands/new/workflow/workflow.command.js +0 -25
- package/dist/commands/new/workflow/workflow.command.js.map +0 -1
- package/dist/commands/new/workflow/workflow.types.d.ts +0 -3
- package/dist/commands/new/workflow/workflow.types.js +0 -3
- package/dist/commands/new/workflow/workflow.types.js.map +0 -1
- package/dist/helpers/sets.d.ts +0 -1
- package/dist/helpers/sets.js +0 -10
- package/dist/helpers/sets.js.map +0 -1
- /package/dist/commands/{install/install.constants.d.ts → init/init.constants.d.ts} +0 -0
|
@@ -5,41 +5,35 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
6
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const prompts_1 = tslib_1.__importDefault(require("prompts"));
|
|
8
|
-
const uuid_1 = require("uuid");
|
|
9
|
-
const core_1 = require("@useparagon/core");
|
|
10
8
|
const project_api_1 = require("../../apis/project.api");
|
|
11
9
|
const codegen_utils_1 = require("../../codegen/codegen.utils");
|
|
12
10
|
const project_compiler_1 = require("../../compiler/compilers/project.compiler");
|
|
13
|
-
const config_1 = require("../../config");
|
|
14
11
|
const spinners_1 = tslib_1.__importDefault(require("../../helpers/spinners"));
|
|
15
12
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
16
|
-
const
|
|
17
|
-
const
|
|
13
|
+
const init_constants_1 = require("./init.constants");
|
|
14
|
+
const init_utils_1 = require("./init.utils");
|
|
18
15
|
class InitAction {
|
|
19
|
-
projectCompiler;
|
|
20
16
|
constructor() {
|
|
21
17
|
this.projectCompiler = new project_compiler_1.ProjectCompiler();
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
handle(options) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
if (options.createFromExisting) {
|
|
22
|
+
yield this.initExistingProject(options);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
yield this.initTemplate(options);
|
|
26
|
+
}
|
|
27
|
+
logger_1.default.success('Created new project.');
|
|
28
|
+
});
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
projectId = config.projectId;
|
|
39
|
-
}
|
|
40
|
-
if (!projectId) {
|
|
41
|
-
const { projectId: projectIdFromPrompt } = await (0, prompts_1.default)({
|
|
42
|
-
type: 'autocomplete',
|
|
30
|
+
initExistingProject(options) {
|
|
31
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
spinners_1.default.add('get-projects', { text: 'Fetching project lists...' });
|
|
33
|
+
const projects = yield (0, project_api_1.getProjectList)();
|
|
34
|
+
spinners_1.default.succeed('get-projects', { text: 'Fetched project lists' });
|
|
35
|
+
const { projectId } = yield (0, prompts_1.default)({
|
|
36
|
+
type: 'select',
|
|
43
37
|
name: 'projectId',
|
|
44
38
|
message: 'Select project',
|
|
45
39
|
choices: projects.map((project) => ({
|
|
@@ -47,78 +41,59 @@ class InitAction {
|
|
|
47
41
|
value: project.id,
|
|
48
42
|
})),
|
|
49
43
|
});
|
|
50
|
-
projectId
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
text: '
|
|
70
|
-
|
|
71
|
-
const project = await (0, project_api_1.getProjectBuild)(projectId);
|
|
72
|
-
spinners_1.default.succeed('import-project', {
|
|
73
|
-
text: 'Imported project contents',
|
|
74
|
-
});
|
|
75
|
-
spinners_1.default.add('build-project', { text: 'Building Project...' });
|
|
76
|
-
await (0, codegen_utils_1.generateProjectFiles)(project, projectSrcPath);
|
|
77
|
-
spinners_1.default.succeed('build-project', {
|
|
78
|
-
text: `Built project in ${projectName}/`,
|
|
44
|
+
if (!projectId) {
|
|
45
|
+
logger_1.default.fatal('No project selected.');
|
|
46
|
+
}
|
|
47
|
+
const projectName = (0, init_utils_1.sanitizeAppName)(projects.find(({ id }) => id === projectId).title);
|
|
48
|
+
const projectRoot = path_1.default.join(process.cwd(), projectName);
|
|
49
|
+
const projectSrcPath = path_1.default.join(projectRoot, 'src');
|
|
50
|
+
yield fs_extra_1.default.promises.mkdir(projectSrcPath, { recursive: true });
|
|
51
|
+
yield fs_extra_1.default.writeFile(path_1.default.join(projectRoot, 'paragon.json'), JSON.stringify({
|
|
52
|
+
projectId,
|
|
53
|
+
}));
|
|
54
|
+
spinners_1.default.add('fetch-project-data', {
|
|
55
|
+
text: 'Fetching project...',
|
|
56
|
+
});
|
|
57
|
+
const project = yield (0, project_api_1.getProjectBuild)(projectId);
|
|
58
|
+
spinners_1.default.succeed('fetch-project-data', {
|
|
59
|
+
text: 'Fetched project',
|
|
60
|
+
});
|
|
61
|
+
spinners_1.default.add('build-project', { text: 'Building Project...' });
|
|
62
|
+
yield (0, codegen_utils_1.generateProjectFiles)(project, projectSrcPath);
|
|
63
|
+
spinners_1.default.succeed('build-project', { text: 'Built Project' });
|
|
64
|
+
yield this.installDependencies(projectRoot, options);
|
|
79
65
|
});
|
|
80
|
-
const integrationToDependencies = Object.fromEntries(Object.entries(project.integrations)
|
|
81
|
-
.filter(([integration, _]) => !(0, core_1.isCustomIntegration)(integration))
|
|
82
|
-
.map(([integration, build]) => [integration, build?.dependencies]));
|
|
83
|
-
await this.installDependencies(projectRoot, options, integrationToDependencies);
|
|
84
66
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
projectName,
|
|
98
|
-
events: {},
|
|
99
|
-
persona: {
|
|
100
|
-
meta: {},
|
|
101
|
-
},
|
|
102
|
-
integrations: {},
|
|
103
|
-
secrets: [],
|
|
104
|
-
};
|
|
105
|
-
await (0, config_1.createParagrahpProjectConfig)(projectRoot, {
|
|
106
|
-
projectId: projectBuild.projectId,
|
|
107
|
-
projectName,
|
|
108
|
-
profile: config_1.DEFAULT_PROFILE,
|
|
67
|
+
initTemplate(options) {
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const projectRoot = path_1.default
|
|
70
|
+
.resolve(options.extraArgs.slice(1).join(''))
|
|
71
|
+
.trim();
|
|
72
|
+
if (process.cwd() === projectRoot) {
|
|
73
|
+
logger_1.default.fatal('Provide project name in init command - para init projectname');
|
|
74
|
+
}
|
|
75
|
+
yield fs_extra_1.default.promises.mkdir(projectRoot, { recursive: true });
|
|
76
|
+
const templatePath = path_1.default.resolve(__dirname, `../../templates/${options.language}`);
|
|
77
|
+
yield fs_extra_1.default.copy(templatePath, projectRoot);
|
|
78
|
+
yield this.installDependencies(projectRoot, options);
|
|
109
79
|
});
|
|
110
|
-
await (0, codegen_utils_1.generateProjectFiles)(projectBuild, projectSrcPath);
|
|
111
|
-
await this.installDependencies(projectRoot, options);
|
|
112
|
-
logger_1.default.success(`Created new project in ${projectName}/`);
|
|
113
80
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
81
|
+
installDependencies(projectRoot, options) {
|
|
82
|
+
var _a;
|
|
83
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const projectName = (0, init_utils_1.sanitizeAppName)(path_1.default.basename(projectRoot));
|
|
85
|
+
const packageManager = (_a = options.packageManager) !== null && _a !== void 0 ? _a : (0, init_utils_1.getPkgManager)();
|
|
86
|
+
const defaultConfigPath = path_1.default.resolve(__dirname, `../../templates/configurations/${options.language}`);
|
|
87
|
+
yield fs_extra_1.default.copy(defaultConfigPath, projectRoot);
|
|
88
|
+
const packageJson = Object.assign({}, init_constants_1.defaultPackageJson);
|
|
89
|
+
packageJson.name = projectName;
|
|
90
|
+
if (options.language === 'typescript') {
|
|
91
|
+
packageJson.dependencies = Object.assign(Object.assign({}, packageJson.dependencies), { tslib: '2.3.1' });
|
|
92
|
+
packageJson.devDependencies = Object.assign(Object.assign({}, packageJson.devDependencies), { typescript: '^4.4.4', '@types/node': '^18.13.0' });
|
|
93
|
+
}
|
|
94
|
+
yield fs_extra_1.default.promises.writeFile(path_1.default.join(projectRoot, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
95
|
+
yield (0, init_utils_1.spawnAsync)(packageManager, ['install'], projectRoot);
|
|
96
|
+
});
|
|
122
97
|
}
|
|
123
98
|
}
|
|
124
99
|
exports.InitAction = InitAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.action.js","sourceRoot":"","sources":["../../../src/commands/init/init.action.ts"],"names":[],"mappings":";;;;AAAA,gEAA0B;AAC1B,wDAAwB;AACxB,8DAA8B;
|
|
1
|
+
{"version":3,"file":"init.action.js","sourceRoot":"","sources":["../../../src/commands/init/init.action.ts"],"names":[],"mappings":";;;;AAAA,gEAA0B;AAC1B,wDAAwB;AACxB,8DAA8B;AAG9B,wDAAyE;AACzE,+DAAmE;AACnE,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AU,EAAE,QAAQ,EACpB,aAAa,EAAE,UAAU,GAC1B,CAAC;YACJ,CAAC;YAED,MAAM,kBAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EACtC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,CAAC;YAEF,MAAM,IAAA,uBAAU,EAAC,cAAc,EAAE,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;;KAC5D;CACF;AAzJD,gCAyJC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InitCommand = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
5
|
const base_api_1 = require("../../apis/base.api");
|
|
6
6
|
const init_action_1 = require("./init.action");
|
|
7
7
|
class InitCommand {
|
|
8
|
-
actionHandler;
|
|
9
8
|
constructor() {
|
|
10
9
|
this.actionHandler = new init_action_1.InitAction();
|
|
11
10
|
}
|
|
@@ -14,21 +13,16 @@ class InitCommand {
|
|
|
14
13
|
.command('init')
|
|
15
14
|
.description('Initialize paragon project')
|
|
16
15
|
.option('--create-from-existing', 'Create from existing project.', false)
|
|
17
|
-
.
|
|
18
|
-
.
|
|
16
|
+
.option('-l,--language [language]', 'Programming language to be used (TypeScript or JavaScript).', 'typescript')
|
|
17
|
+
.option('-p, --package-manager [packageManager]', 'Specify package manager.')
|
|
18
|
+
.action((rawOptions) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const options = this.sanitizeOptions(rawOptions);
|
|
20
|
-
|
|
21
|
-
return this.actionHandler.handle({
|
|
22
|
-
|
|
23
|
-
extraArgs: program.args,
|
|
24
|
-
});
|
|
25
|
-
});
|
|
20
|
+
yield (0, base_api_1.getToken)();
|
|
21
|
+
return this.actionHandler.handle(Object.assign(Object.assign({}, options), { extraArgs: program.args }));
|
|
22
|
+
}));
|
|
26
23
|
}
|
|
27
24
|
sanitizeOptions(rawOptions) {
|
|
28
|
-
return
|
|
29
|
-
...rawOptions,
|
|
30
|
-
language: 'typescript',
|
|
31
|
-
};
|
|
25
|
+
return rawOptions;
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
28
|
exports.InitCommand = InitCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.command.js","sourceRoot":"","sources":["../../../src/commands/init/init.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.command.js","sourceRoot":"","sources":["../../../src/commands/init/init.command.ts"],"names":[],"mappings":";;;;AAEA,kDAA+C;AAO/C,+CAA2C;AAM3C,MAAa,WAAW;IAGtB;QACE,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAU,EAAE,CAAC;IACxC,CAAC;IAKD,IAAI,CAAC,OAAgB;QACnB,OAAO;aACJ,OAAO,CAAC,MAAM,CAAC;aACf,WAAW,CAAC,4BAA4B,CAAC;aACzC,MAAM,CAAC,wBAAwB,EAAE,+BAA+B,EAAE,KAAK,CAAC;aASxE,MAAM,CACL,0BAA0B,EAC1B,6DAA6D,EAC7D,YAAY,CACb;aAOA,MAAM,CACL,wCAAwC,EACxC,0BAA0B,CAC3B;aACA,MAAM,CAAC,CAAO,UAA8B,EAAE,EAAE;YAC/C,MAAM,OAAO,GAAuB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YAGrE,MAAM,IAAA,mBAAQ,GAAE,CAAC;YAEjB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,iCAC3B,OAAO,KACV,SAAS,EAAE,OAAO,CAAC,IAAI,IACvB,CAAC;QACL,CAAC,CAAA,CAAC,CAAC;IACP,CAAC;IAOO,eAAe,CAAC,UAA8B;QACpD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA3DD,kCA2DC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultPackageJson = void 0;
|
|
4
|
+
exports.defaultPackageJson = {
|
|
5
|
+
name: 'default-package.json',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
private: true,
|
|
8
|
+
engines: {
|
|
9
|
+
node: '>=14.17',
|
|
10
|
+
},
|
|
11
|
+
scripts: {
|
|
12
|
+
build: 'para build',
|
|
13
|
+
},
|
|
14
|
+
dependencies: {},
|
|
15
|
+
devDependencies: {
|
|
16
|
+
'@trivago/prettier-plugin-sort-imports': '^4.2.0',
|
|
17
|
+
prettier: '^3.1.0',
|
|
18
|
+
'prettier-plugin-organize-imports': '^3.2.3',
|
|
19
|
+
'@types/node': '^18.13.0',
|
|
20
|
+
typescript: '^5.3.2',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=init.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.constants.js","sourceRoot":"","sources":["../../../src/commands/init/init.constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,kBAAkB,GAAwB;IACrD,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,IAAI;IACb,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;KAChB;IACD,OAAO,EAAE;QACP,KAAK,EAAE,YAAY;KACpB;IAID,YAAY,EAAE,EAGb;IAID,eAAe,EAAE;QACf,uCAAuC,EAAE,QAAQ;QACjD,QAAQ,EAAE,QAAQ;QAClB,kCAAkC,EAAE,QAAQ;QAC5C,aAAa,EAAE,UAAU;QACzB,UAAU,EAAE,QAAQ;KACrB;CACF,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { KNOWN_PACKAGE_MANAGERS } from '../../helpers/constants';
|
|
|
2
2
|
export type InitCommandOptions = {
|
|
3
3
|
language: 'javascript' | 'typescript';
|
|
4
4
|
createFromExisting: boolean;
|
|
5
|
-
autoDetectProject: boolean;
|
|
6
5
|
packageManager: (typeof KNOWN_PACKAGE_MANAGERS)[number];
|
|
7
6
|
extraArgs: any[];
|
|
8
7
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { KNOWN_PACKAGE_MANAGERS } from './../../helpers/constants';
|
|
2
|
+
export declare function getPkgManager(): (typeof KNOWN_PACKAGE_MANAGERS)[number];
|
|
3
|
+
export type GenericResolve<T = any> = {
|
|
4
|
+
(value?: T): void;
|
|
5
|
+
};
|
|
6
|
+
export type GenericReject<T = Error> = {
|
|
7
|
+
(error: T): void;
|
|
8
|
+
};
|
|
9
|
+
export declare function spawnAsync(command: string, args: string[], path: string): Promise<number>;
|
|
10
|
+
export declare const sanitizeAppName: (appName: string) => string;
|
|
11
|
+
export declare const sleep: (seconds: number) => Promise<void>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sleep = exports.sanitizeAppName = exports.spawnAsync = exports.getPkgManager = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
function getPkgManager() {
|
|
6
|
+
const userAgent = process.env.npm_config_user_agent || '';
|
|
7
|
+
if (userAgent.startsWith('yarn')) {
|
|
8
|
+
return 'yarn';
|
|
9
|
+
}
|
|
10
|
+
if (userAgent.startsWith('pnpm')) {
|
|
11
|
+
return 'pnpm';
|
|
12
|
+
}
|
|
13
|
+
if (userAgent.startsWith('bun')) {
|
|
14
|
+
return 'bun';
|
|
15
|
+
}
|
|
16
|
+
return 'npm';
|
|
17
|
+
}
|
|
18
|
+
exports.getPkgManager = getPkgManager;
|
|
19
|
+
function spawnAsync(command, args, path) {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
const childProcess = (0, child_process_1.spawn)(command, args, {
|
|
22
|
+
stdio: 'inherit',
|
|
23
|
+
env: {},
|
|
24
|
+
cwd: path,
|
|
25
|
+
});
|
|
26
|
+
childProcess.on('exit', (code) => {
|
|
27
|
+
if (code !== 0) {
|
|
28
|
+
return reject(new Error(`Failed command '${command} ${args.join(' ')}' with exit code ${code}`));
|
|
29
|
+
}
|
|
30
|
+
return resolve(code);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.spawnAsync = spawnAsync;
|
|
35
|
+
const sanitizeAppName = (appName) => {
|
|
36
|
+
return appName
|
|
37
|
+
.replace(/([a-z\d])([A-Z])/g, '$1-$2')
|
|
38
|
+
.toLowerCase()
|
|
39
|
+
.replace(/\s/g, '-');
|
|
40
|
+
};
|
|
41
|
+
exports.sanitizeAppName = sanitizeAppName;
|
|
42
|
+
const sleep = (seconds) => {
|
|
43
|
+
return new Promise((res, _rej) => {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
res();
|
|
46
|
+
}, seconds * 1000);
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
exports.sleep = sleep;
|
|
50
|
+
//# sourceMappingURL=init.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.utils.js","sourceRoot":"","sources":["../../../src/commands/init/init.utils.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AAOpD,SAAgB,aAAa;IAC3B,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAE1D,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAhBD,sCAgBC;AAiBD,SAAgB,UAAU,CACxB,OAAe,EACf,IAAc,EACd,IAAY;IAEZ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAuB,EAAE,MAAsB,EAAE,EAAE;QACrE,MAAM,YAAY,GAAiB,IAAA,qBAAK,EAAC,OAAO,EAAE,IAAI,EAAE;YACtD,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,EAAE;YACP,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;QAEH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;YACvC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,MAAM,CACX,IAAI,KAAK,CACP,mBAAmB,OAAO,IAAI,IAAI,CAAC,IAAI,CACrC,GAAG,CACJ,oBAAoB,IAAI,EAAE,CAC5B,CACF,CAAC;YACJ,CAAC;YAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA1BD,gCA0BC;AAOM,MAAM,eAAe,GAAG,CAAC,OAAe,EAAU,EAAE;IACzD,OAAO,OAAO;SACX,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC;SACrC,WAAW,EAAE;SACb,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC;AALW,QAAA,eAAe,mBAK1B;AAMK,MAAM,KAAK,GAAG,CAAC,OAAe,EAAiB,EAAE;IACtD,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QAC/B,UAAU,CAAC,GAAG,EAAE;YACd,GAAG,EAAE,CAAC;QACR,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AANW,QAAA,KAAK,SAMhB"}
|
|
@@ -6,15 +6,17 @@ const apis_1 = require("../../apis");
|
|
|
6
6
|
const config_1 = require("../../config");
|
|
7
7
|
const spinners_1 = tslib_1.__importDefault(require("../../helpers/spinners"));
|
|
8
8
|
class PushAction {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
handle(_options) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const { projectId } = yield (0, config_1.getParagraphProjectDetails)();
|
|
12
|
+
const projectBuild = yield (0, config_1.getLocalProjectBuild)();
|
|
13
|
+
spinners_1.default.add('writing-output', {
|
|
14
|
+
text: `Pushing changes to paragon cloud`,
|
|
15
|
+
});
|
|
16
|
+
yield (0, apis_1.syncProject)(projectId, projectBuild);
|
|
17
|
+
spinners_1.default.succeed('writing-output', {
|
|
18
|
+
text: `Pushed changes to paragon cloud`,
|
|
19
|
+
});
|
|
18
20
|
});
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.action.js","sourceRoot":"","sources":["../../../src/commands/push/push.action.ts"],"names":[],"mappings":";;;;AAAA,qCAAuD;AACvD,yCAAgF;AAChF,8EAA8C;AAO9C,MAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"push.action.js","sourceRoot":"","sources":["../../../src/commands/push/push.action.ts"],"names":[],"mappings":";;;;AAAA,qCAAuD;AACvD,yCAAgF;AAChF,8EAA8C;AAO9C,MAAa,UAAU;IAIf,MAAM,CAAC,QAA4B;;YACvC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,mCAA0B,GAAE,CAAC;YACzD,MAAM,YAAY,GAAiB,MAAM,IAAA,6BAAoB,GAAE,CAAC;YAEhE,kBAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE;gBAC7B,IAAI,EAAE,kCAAkC;aACzC,CAAC,CAAC;YAEH,MAAM,IAAA,kBAAW,EAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YAE3C,kBAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE;gBACjC,IAAI,EAAE,iCAAiC;aACxC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAlBD,gCAkBC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PushCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const base_api_1 = require("../../apis/base.api");
|
|
5
6
|
const push_action_1 = require("./push.action");
|
|
6
7
|
class PushCommand {
|
|
7
|
-
actionHandler;
|
|
8
8
|
constructor() {
|
|
9
9
|
this.actionHandler = new push_action_1.PushAction();
|
|
10
10
|
}
|
|
@@ -12,11 +12,11 @@ class PushCommand {
|
|
|
12
12
|
program
|
|
13
13
|
.command('push')
|
|
14
14
|
.description('Push changes to cloud')
|
|
15
|
-
.action(
|
|
15
|
+
.action((rawOptions) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
const options = this.sanitizeOptions(rawOptions);
|
|
17
|
-
|
|
17
|
+
yield (0, base_api_1.getToken)();
|
|
18
18
|
return this.actionHandler.handle(options);
|
|
19
|
-
});
|
|
19
|
+
}));
|
|
20
20
|
}
|
|
21
21
|
sanitizeOptions(rawOptions) {
|
|
22
22
|
return rawOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.command.js","sourceRoot":"","sources":["../../../src/commands/push/push.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"push.command.js","sourceRoot":"","sources":["../../../src/commands/push/push.command.ts"],"names":[],"mappings":";;;;AAEA,kDAA+C;AAG/C,+CAA2C;AAM3C,MAAa,WAAW;IAGtB;QACE,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAU,EAAE,CAAC;IACxC,CAAC;IAKD,IAAI,CAAC,OAAgB;QACnB,OAAO;aACJ,OAAO,CAAC,MAAM,CAAC;aACf,WAAW,CAAC,uBAAuB,CAAC;aACpC,MAAM,CAAC,CAAO,UAA8B,EAAE,EAAE;YAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YAGjD,MAAM,IAAA,mBAAQ,GAAE,CAAC;YAEjB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC,CAAA,CAAC,CAAC;IACP,CAAC;IAOO,eAAe,CAAC,UAA8B;QACpD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAhCD,kCAgCC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IEvent } from '@useparagon/core/event';
|
|
2
2
|
export type ProjectDependencies = {
|
|
3
3
|
projectId: string;
|
|
4
|
-
|
|
5
|
-
secrets: ISecret[];
|
|
4
|
+
events: Record<string, IEvent>;
|
|
6
5
|
};
|
|
7
6
|
export type WorkflowDependencies = ProjectDependencies & {
|
|
8
7
|
integration: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const extractKeyFromPath: (filePath: string) => string;
|
|
2
|
-
export declare const requireSafe: <T>(filePath: string
|
|
2
|
+
export declare const requireSafe: <T>(filePath: string) => T;
|
|
@@ -6,21 +6,17 @@ const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
|
6
6
|
const extractKeyFromPath = (filePath) => {
|
|
7
7
|
const names = filePath.split('/');
|
|
8
8
|
const fileName = names[names.length - 1];
|
|
9
|
-
if (fileName.endsWith('.js')
|
|
9
|
+
if (fileName.endsWith('.js')) {
|
|
10
10
|
return fileName.slice(0, -3);
|
|
11
11
|
}
|
|
12
12
|
return fileName;
|
|
13
13
|
};
|
|
14
14
|
exports.extractKeyFromPath = extractKeyFromPath;
|
|
15
|
-
const requireSafe = (filePath
|
|
15
|
+
const requireSafe = (filePath) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
if (onlyUseDefault) {
|
|
19
|
-
return output.default;
|
|
20
|
-
}
|
|
21
|
-
return output;
|
|
17
|
+
return require(filePath).default;
|
|
22
18
|
}
|
|
23
|
-
catch {
|
|
19
|
+
catch (_a) {
|
|
24
20
|
logger_1.default.fatal(`Could not found ${filePath}.`);
|
|
25
21
|
}
|
|
26
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.utils.js","sourceRoot":"","sources":["../../src/compiler/compiler.utils.ts"],"names":[],"mappings":";;;;AAAA,+DAA+B;AAOxB,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC7D,MAAM,KAAK,GAAa,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAW,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAGjD,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"compiler.utils.js","sourceRoot":"","sources":["../../src/compiler/compiler.utils.ts"],"names":[],"mappings":";;;;AAAA,+DAA+B;AAOxB,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC7D,MAAM,KAAK,GAAa,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAW,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAGjD,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAVW,QAAA,kBAAkB,sBAU7B;AAOK,MAAM,WAAW,GAAG,CAAI,QAAgB,EAAK,EAAE;IACpD,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAY,CAAC;IACxC,CAAC;IAAC,WAAM,CAAC;QACP,gBAAM,CAAC,KAAK,CAAC,mBAAmB,QAAQ,GAAG,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB"}
|
|
@@ -5,34 +5,38 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const glob_1 = require("glob");
|
|
6
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const uuid_1 = require("uuid");
|
|
8
|
+
const spinners_1 = tslib_1.__importDefault(require("../../helpers/spinners"));
|
|
8
9
|
const compiler_utils_1 = require("../compiler.utils");
|
|
9
10
|
class EventsCompiler {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
const eventsMap = {};
|
|
19
|
-
for (const eventPath of userEventPaths) {
|
|
20
|
-
const userDefinedEvent = (0, compiler_utils_1.requireSafe)(path_1.default.join(projectRoot, eventPath));
|
|
21
|
-
if (eventsMap[userDefinedEvent.name]) {
|
|
22
|
-
throw new Error(`Event with name "${userDefinedEvent.name}" is already defined.`);
|
|
11
|
+
compile(options) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const { projectRoot, previousEvents } = options;
|
|
14
|
+
const userEventPaths = (yield (0, glob_1.glob)(path_1.default.join(projectRoot, 'events/*.js'))).map(compiler_utils_1.extractKeyFromPath);
|
|
15
|
+
if (!userEventPaths.length) {
|
|
16
|
+
return [];
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
userEvent.
|
|
18
|
+
spinners_1.default.add(`compile-event`, {
|
|
19
|
+
text: `building event`,
|
|
20
|
+
indent: 2,
|
|
21
|
+
});
|
|
22
|
+
const eventsMap = {};
|
|
23
|
+
for (const eventPath of userEventPaths) {
|
|
24
|
+
const userEvent = Object.assign(Object.assign({}, (0, compiler_utils_1.requireSafe)(eventPath)), { id: (0, uuid_1.v4)() });
|
|
25
|
+
if (eventsMap[userEvent.name]) {
|
|
26
|
+
throw new Error(`Event with name "${userEvent.name}" is already defined.`);
|
|
27
|
+
}
|
|
28
|
+
const previousEvent = previousEvents.find((previousEvent) => previousEvent.name === userEvent.name);
|
|
29
|
+
if (previousEvent) {
|
|
30
|
+
userEvent.id = previousEvent.id;
|
|
31
|
+
}
|
|
32
|
+
eventsMap[userEvent.name] = userEvent;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
spinners_1.default.succeed(`compile-event`, {
|
|
35
|
+
text: `built events`,
|
|
36
|
+
indent: 2,
|
|
37
|
+
});
|
|
38
|
+
return Object.values(eventsMap);
|
|
39
|
+
});
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
exports.EventsCompiler = EventsCompiler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.compiler.js","sourceRoot":"","sources":["../../../src/compiler/compilers/events.compiler.ts"],"names":[],"mappings":";;;;AAAA,+BAA4B;AAC5B,wDAAwB;AACxB,+BAA0B;
|
|
1
|
+
{"version":3,"file":"events.compiler.js","sourceRoot":"","sources":["../../../src/compiler/compilers/events.compiler.ts"],"names":[],"mappings":";;;;AAAA,+BAA4B;AAC5B,wDAAwB;AACxB,+BAA0B;AAI1B,8EAA8C;AAE9C,sDAAoE;AAUpE,MAAa,cAAc;IAQnB,OAAO,CAAC,OAA4B;;YACxC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;YAEhD,MAAM,cAAc,GAAa,CAC/B,MAAM,IAAA,WAAI,EAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,CAClD,CAAC,GAAG,CAAC,mCAAkB,CAAC,CAAC;YAE1B,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;gBAC3B,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,kBAAQ,CAA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