@scifeon/sdk 0.100.0 → 0.102.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.
Files changed (99) hide show
  1. package/dist/action-target.d.ts +6 -6
  2. package/dist/action-target.js +10 -10
  3. package/dist/app/app-generator.d.ts +34 -34
  4. package/dist/app/app-generator.js +460 -460
  5. package/dist/app/app-persist.d.ts +18 -18
  6. package/dist/app/app-persist.js +193 -193
  7. package/dist/app/app-validator.d.ts +8 -8
  8. package/dist/app/app-validator.js +145 -145
  9. package/dist/app/interfaces/app-json.interface.d.ts +4 -4
  10. package/dist/app/interfaces/app-json.interface.js +2 -2
  11. package/dist/app/interfaces/app-type.enum.d.ts +5 -5
  12. package/dist/app/interfaces/app-type.enum.js +9 -9
  13. package/dist/app/interfaces/contributions/contributions-json.interface.d.ts +55 -55
  14. package/dist/app/interfaces/contributions/contributions-json.interface.js +2 -2
  15. package/dist/app/interfaces/contributions/main-menu.interface.d.ts +12 -12
  16. package/dist/app/interfaces/contributions/main-menu.interface.js +2 -2
  17. package/dist/app/interfaces/contributions/menu-item.interface.d.ts +5 -5
  18. package/dist/app/interfaces/contributions/menu-item.interface.js +2 -2
  19. package/dist/app/interfaces/contributions/page-menu-item.interface.d.ts +10 -10
  20. package/dist/app/interfaces/contributions/page-menu-item.interface.js +2 -2
  21. package/dist/app/interfaces/contributions/page-menu.interface.d.ts +9 -9
  22. package/dist/app/interfaces/contributions/page-menu.interface.js +2 -2
  23. package/dist/app/interfaces/package-json.interface.d.ts +14 -14
  24. package/dist/app/interfaces/package-json.interface.js +2 -2
  25. package/dist/app/interfaces/webpack-config.interface.d.ts +5 -5
  26. package/dist/app/interfaces/webpack-config.interface.js +2 -2
  27. package/dist/cli/commands/app/build.d.ts +4 -4
  28. package/dist/cli/commands/app/build.js +43 -43
  29. package/dist/cli/commands/app/clean.d.ts +3 -3
  30. package/dist/cli/commands/app/clean.js +15 -15
  31. package/dist/cli/commands/app/debug.d.ts +3 -3
  32. package/dist/cli/commands/app/debug.js +22 -22
  33. package/dist/cli/commands/app/e2e-test.d.ts +3 -3
  34. package/dist/cli/commands/app/e2e-test.js +23 -23
  35. package/dist/cli/commands/app/new.d.ts +6 -6
  36. package/dist/cli/commands/app/new.js +190 -190
  37. package/dist/cli/commands/app/package.d.ts +3 -3
  38. package/dist/cli/commands/app/package.js +10 -10
  39. package/dist/cli/commands/app/post-process.d.ts +8 -8
  40. package/dist/cli/commands/app/post-process.js +122 -122
  41. package/dist/cli/commands/app/scaffold.d.ts +4 -4
  42. package/dist/cli/commands/app/scaffold.js +19 -19
  43. package/dist/cli/commands/app/unit-test.d.ts +3 -3
  44. package/dist/cli/commands/app/unit-test.js +11 -11
  45. package/dist/cli/commands/app/validate.d.ts +3 -3
  46. package/dist/cli/commands/app/validate.js +20 -20
  47. package/dist/cli/commands/app/version.d.ts +3 -3
  48. package/dist/cli/commands/app/version.js +17 -17
  49. package/dist/cli/commands/app/watch.d.ts +3 -3
  50. package/dist/cli/commands/app/watch.js +48 -48
  51. package/dist/cli/commands/scifeon/download.d.ts +3 -3
  52. package/dist/cli/commands/scifeon/download.js +48 -48
  53. package/dist/cli/commands/scifeon/run.d.ts +3 -3
  54. package/dist/cli/commands/scifeon/run.js +41 -41
  55. package/dist/cli/config.d.ts +11 -11
  56. package/dist/cli/config.js +23 -23
  57. package/dist/cli/index.d.ts +9 -9
  58. package/dist/cli/index.js +159 -159
  59. package/dist/cli/webpack-runner.d.ts +1 -1
  60. package/dist/cli/webpack-runner.js +26 -26
  61. package/dist/download-utils.d.ts +3 -3
  62. package/dist/download-utils.js +50 -50
  63. package/dist/file-utils.d.ts +5 -5
  64. package/dist/file-utils.js +41 -41
  65. package/dist/html-report.d.ts +15 -15
  66. package/dist/html-report.js +212 -212
  67. package/dist/index.d.ts +2 -2
  68. package/dist/index.js +23 -23
  69. package/dist/logger.d.ts +14 -14
  70. package/dist/logger.js +52 -52
  71. package/dist/measurement-units.d.ts +5 -5
  72. package/dist/measurement-units.js +9 -9
  73. package/dist/page-types.d.ts +6 -6
  74. package/dist/page-types.js +10 -10
  75. package/dist/plugin-types.d.ts +43 -42
  76. package/dist/plugin-types.js +47 -46
  77. package/dist/unit-test-runner.d.ts +1 -1
  78. package/dist/unit-test-runner.js +82 -82
  79. package/dist/utils/test-helper.d.ts +4 -4
  80. package/dist/utils/test-helper.js +46 -46
  81. package/dist/webpack-app-config.d.ts +2 -2
  82. package/dist/webpack-app-config.js +248 -248
  83. package/dist/webpack-utils.d.ts +8 -8
  84. package/dist/webpack-utils.js +91 -91
  85. package/package.json +72 -72
  86. package/resources/new-app/README.md +12 -12
  87. package/resources/new-app/editor/.vscode/launch.json +40 -40
  88. package/resources/new-app/gitignore.txt +6 -6
  89. package/resources/new-app/typescript/src/index.html +14 -14
  90. package/resources/new-app/typescript/src/index.ts +32 -32
  91. package/resources/new-app/typescript/test/e2e/frontpage.test.ts +16 -16
  92. package/resources/new-app/typescript/test/e2e-config.ts +14 -14
  93. package/resources/new-app/typescript/test/unit/index.test.ts +7 -7
  94. package/resources/new-app/typescript/tsconfig.json +39 -39
  95. package/resources/scaffold-templates/scaffold-e2e-test.ts +19 -19
  96. package/resources/test/chai.js +10706 -10706
  97. package/resources/test/mocha.css +326 -326
  98. package/resources/test/mocha.js +16590 -16590
  99. package/resources/test/tests.html +26 -26
@@ -1,43 +1,43 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BuildCommand = void 0;
13
- const fs = require("fs");
14
- const path = require("path");
15
- const download_utils_1 = require("../../../download-utils");
16
- const config_1 = require("../../config");
17
- const webpack_runner_1 = require("../../webpack-runner");
18
- class BuildCommand {
19
- execute(options) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- if (!fs.existsSync(config_1.config.wwwDir) || (options === null || options === void 0 ? void 0 : options.branch)) {
22
- let branch = "";
23
- if (options === null || options === void 0 ? void 0 : options.branch) {
24
- branch = `-${options.branch}`;
25
- branch = branch.replace(/\//ig, "-");
26
- }
27
- try {
28
- yield this.downloadTypes(branch);
29
- }
30
- catch (_a) {
31
- yield this.downloadTypes();
32
- }
33
- }
34
- (0, webpack_runner_1.webpackRunner)("build");
35
- });
36
- }
37
- downloadTypes(branch) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- yield download_utils_1.DownloadUtils.downloadZip(`https://scifeon.azureedge.net/sdk/packages-types${branch}.zip`, path.resolve("runtime", "scifeon", "generated"), `Downloading Scifeon Types ${branch}`);
40
- });
41
- }
42
- }
43
- exports.BuildCommand = BuildCommand;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BuildCommand = void 0;
13
+ const fs = require("fs");
14
+ const path = require("path");
15
+ const download_utils_1 = require("../../../download-utils");
16
+ const config_1 = require("../../config");
17
+ const webpack_runner_1 = require("../../webpack-runner");
18
+ class BuildCommand {
19
+ execute(options) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ if (!fs.existsSync(config_1.config.wwwDir) || (options === null || options === void 0 ? void 0 : options.branch)) {
22
+ let branch = "";
23
+ if (options === null || options === void 0 ? void 0 : options.branch) {
24
+ branch = `-${options.branch}`;
25
+ branch = branch.replace(/\//ig, "-");
26
+ }
27
+ try {
28
+ yield this.downloadTypes(branch);
29
+ }
30
+ catch (_a) {
31
+ yield this.downloadTypes();
32
+ }
33
+ }
34
+ (0, webpack_runner_1.webpackRunner)("build");
35
+ });
36
+ }
37
+ downloadTypes(branch) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ yield download_utils_1.DownloadUtils.downloadZip(`https://scifeon.azureedge.net/sdk/packages-types${branch}.zip`, path.resolve("runtime", "scifeon", "generated"), `Downloading Scifeon Types ${branch}`);
40
+ });
41
+ }
42
+ }
43
+ exports.BuildCommand = BuildCommand;
@@ -1,3 +1,3 @@
1
- export declare class CleanCommand {
2
- execute(): void;
3
- }
1
+ export declare class CleanCommand {
2
+ execute(): void;
3
+ }
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CleanCommand = void 0;
4
- const path = require("path");
5
- const file_utils_1 = require("../../../file-utils");
6
- const logger_1 = require("../../../logger");
7
- class CleanCommand {
8
- execute() {
9
- const buildPath = path.resolve("build");
10
- logger_1.LOGGER.msg("Removing " + buildPath + "...");
11
- file_utils_1.FileUtils.removeDirRecurSync(buildPath);
12
- logger_1.LOGGER.msg(buildPath + " removed successfully.");
13
- }
14
- }
15
- exports.CleanCommand = CleanCommand;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CleanCommand = void 0;
4
+ const path = require("path");
5
+ const file_utils_1 = require("../../../file-utils");
6
+ const logger_1 = require("../../../logger");
7
+ class CleanCommand {
8
+ execute() {
9
+ const buildPath = path.resolve("build");
10
+ logger_1.LOGGER.msg("Removing " + buildPath + "...");
11
+ file_utils_1.FileUtils.removeDirRecurSync(buildPath);
12
+ logger_1.LOGGER.msg(buildPath + " removed successfully.");
13
+ }
14
+ }
15
+ exports.CleanCommand = CleanCommand;
@@ -1,3 +1,3 @@
1
- export declare class DebugCommand {
2
- execute(disableBrowserLaunch: any): Promise<void>;
3
- }
1
+ export declare class DebugCommand {
2
+ execute(disableBrowserLaunch: any): Promise<void>;
3
+ }
@@ -1,22 +1,22 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DebugCommand = void 0;
13
- const run_1 = require("../scifeon/run");
14
- const watch_1 = require("./watch");
15
- class DebugCommand {
16
- execute(disableBrowserLaunch) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- yield new watch_1.WatchCommand().execute(disableBrowserLaunch, new run_1.RunCommand().execute);
19
- });
20
- }
21
- }
22
- exports.DebugCommand = DebugCommand;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DebugCommand = void 0;
13
+ const run_1 = require("../scifeon/run");
14
+ const watch_1 = require("./watch");
15
+ class DebugCommand {
16
+ execute(disableBrowserLaunch) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ yield new watch_1.WatchCommand().execute(disableBrowserLaunch, new run_1.RunCommand().execute);
19
+ });
20
+ }
21
+ }
22
+ exports.DebugCommand = DebugCommand;
@@ -1,3 +1,3 @@
1
- export declare class E2ETestCommand {
2
- execute(options: any): void;
3
- }
1
+ export declare class E2ETestCommand {
2
+ execute(options: any): void;
3
+ }
@@ -1,23 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.E2ETestCommand = void 0;
4
- const path = require("path");
5
- const resolve = require("resolve");
6
- const logger_1 = require("../../../logger");
7
- class E2ETestCommand {
8
- execute(options) {
9
- if (__dirname.includes(`${path.sep}packages${path.sep}sdk${path.sep}`)) {
10
- require("../../../../../e2e-test/dist").e2eTestRunner(options);
11
- return;
12
- }
13
- resolve("@scifeon/e2e-test", { basedir: process.cwd() }, (err, res) => {
14
- if (err) {
15
- logger_1.LOGGER.error(`You must install the @scifeon/e2e-test package to use this command: 'npm install @scifeon/e2e-test --save-dev'`);
16
- }
17
- else {
18
- require(res).e2eTestRunner(options);
19
- }
20
- });
21
- }
22
- }
23
- exports.E2ETestCommand = E2ETestCommand;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.E2ETestCommand = void 0;
4
+ const path = require("path");
5
+ const resolve = require("resolve");
6
+ const logger_1 = require("../../../logger");
7
+ class E2ETestCommand {
8
+ execute(options) {
9
+ if (__dirname.includes(`${path.sep}packages${path.sep}sdk${path.sep}`)) {
10
+ require("../../../../../e2e-test/dist").e2eTestRunner(options);
11
+ return;
12
+ }
13
+ resolve("@scifeon/e2e-test", { basedir: process.cwd() }, (err, res) => {
14
+ if (err) {
15
+ logger_1.LOGGER.error(`You must install the @scifeon/e2e-test package to use this command: 'npm install @scifeon/e2e-test --save-dev'`);
16
+ }
17
+ else {
18
+ require(res).e2eTestRunner(options);
19
+ }
20
+ });
21
+ }
22
+ }
23
+ exports.E2ETestCommand = E2ETestCommand;
@@ -1,6 +1,6 @@
1
- export declare class NewCommand {
2
- constructor();
3
- execute(): void;
4
- private parseResult;
5
- private copyResources;
6
- }
1
+ export declare class NewCommand {
2
+ constructor();
3
+ execute(): void;
4
+ private parseResult;
5
+ private copyResources;
6
+ }
@@ -1,190 +1,190 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NewCommand = void 0;
4
- const child_process_1 = require("child_process");
5
- const fs = require("fs");
6
- const path = require("path");
7
- const prompt = require("prompt");
8
- const file_utils_1 = require("../../../file-utils");
9
- const logger_1 = require("../../../logger");
10
- const download_1 = require("../scifeon/download");
11
- class NewCommand {
12
- constructor() {
13
- prompt.message = "";
14
- prompt.delimiter = ":";
15
- }
16
- execute() {
17
- prompt.start();
18
- const packageJson = {
19
- properties: {
20
- name: {
21
- description: "Name (used for directory name, e.g. 'science_app')",
22
- pattern: /^[a-zA-Z\_]+$/,
23
- message: "Name must be only letters and underscores (_)",
24
- required: true,
25
- },
26
- displayName: {
27
- description: "Display Name (used in Administration interface, e.g. 'Awesome Scifeon App'. If empty, name is used)",
28
- },
29
- namespace: {
30
- description: "Namespace (e.g. 'com.scifeon')",
31
- required: true,
32
- pattern: /^[a-zA-Z\.]+$/,
33
- message: "Namespace must be only letters and dots",
34
- },
35
- author: {
36
- description: "Author (e.g. 'Demo Inc.')",
37
- required: true,
38
- message: "Author must not be empty",
39
- },
40
- description: {
41
- description: "Description",
42
- required: true,
43
- message: "Description must not be empty",
44
- },
45
- editor: {
46
- description: "Editor (vscode or none)",
47
- default: "vscode",
48
- },
49
- unit: {
50
- description: "Include Unit tests (yes or no)",
51
- default: "yes",
52
- },
53
- e2e: {
54
- description: "Include E2E tests (yes or no)",
55
- default: "yes",
56
- },
57
- },
58
- };
59
- prompt.get(packageJson, (err, result) => this.parseResult(err, result));
60
- }
61
- parseResult(err, packageJson) {
62
- if (err) {
63
- return;
64
- }
65
- if (fs.existsSync(packageJson.name)) {
66
- throw new Error("A folder with the name '" + packageJson.name + "' already exists.");
67
- }
68
- fs.mkdirSync(packageJson.name);
69
- packageJson.version = "0.0.1";
70
- packageJson.scifeon = {};
71
- if (!packageJson.displayName) {
72
- packageJson.name = packageJson.displayName;
73
- }
74
- const cliPackageJson = require(path.resolve(__dirname, "..", "..", "..", "..", "package.json"));
75
- packageJson.scifeon.cliVersion = cliPackageJson.version;
76
- packageJson.dependencies = {
77
- "aurelia-bootstrapper": cliPackageJson.dependencies["aurelia-bootstrapper"],
78
- };
79
- packageJson.devDependencies = {
80
- "@scifeon/sdk": "^" + packageJson.scifeon.cliVersion,
81
- "tslib": cliPackageJson.dependencies.tslib,
82
- };
83
- if (packageJson.e2e.trim() === "yes") {
84
- packageJson.devDependencies["@scifeon/e2e-test"] = "^0.33.0";
85
- }
86
- if (packageJson.e2e.trim() === "yes" || packageJson.unit.trim() === "yes") {
87
- packageJson.devDependencies["@types/chai"] = cliPackageJson.dependencies["@types/chai"];
88
- packageJson.devDependencies["@types/mocha"] = cliPackageJson.dependencies["@types/mocha"];
89
- }
90
- const contributionsJson = {
91
- menu: {
92
- main: [{
93
- text: "Custom Page: " + packageJson.namespace + "." + packageJson.name,
94
- route: "app/" + packageJson.namespace + "/" + packageJson.name,
95
- }],
96
- },
97
- };
98
- this.copyResources(packageJson);
99
- delete packageJson.e2e;
100
- delete packageJson.unit;
101
- new download_1.DownloadCommand().execute(packageJson.name)
102
- .then(() => {
103
- const versionFile = path.resolve(packageJson.name, "runtime", "scifeon", "VERSION");
104
- packageJson.scifeon.runtimeVersion = fs.readFileSync(versionFile).toString();
105
- fs.writeFileSync(path.resolve(packageJson.name, "package.json"), JSON.stringify(packageJson, null, 2));
106
- fs.writeFileSync(path.resolve(packageJson.name, "contributions.json"), JSON.stringify(contributionsJson, null, 2));
107
- logger_1.LOGGER.msg("Installing node_modules...");
108
- const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
109
- const proc = (0, child_process_1.spawn)(npmCmd, ["install --silent --prefer-offline --no-audit"], { cwd: path.resolve(packageJson.name) });
110
- proc.stderr.on("data", (data) => console.log(data.toString()));
111
- proc.stdout.on("data", (data) => console.log(data.toString()));
112
- proc.once("exit", () => logger_1.LOGGER.msg("App created in folder [" + packageJson.name + "]. Run 'scifeon-cli debug' in this directory to start development of your app."));
113
- });
114
- }
115
- copyResources(packageJson) {
116
- const resources = ["README.md"];
117
- resources.push({
118
- from: "gitignore.txt",
119
- to: ".gitignore",
120
- });
121
- if (packageJson.editor.toLowerCase().trim() === "vscode") {
122
- resources.push({
123
- from: "editor" + path.sep + ".vscode" + path.sep + "launch.json",
124
- to: "launch.json",
125
- toFolder: ".vscode",
126
- });
127
- }
128
- delete packageJson.editor;
129
- resources.push({
130
- from: "typescript" + path.sep + "tsconfig.json",
131
- to: "tsconfig.json",
132
- });
133
- resources.push({
134
- from: "typescript" + path.sep + "src" + path.sep + "index.ts",
135
- to: "index.ts",
136
- toFolder: "src" + path.sep + "pages",
137
- });
138
- resources.push({
139
- from: "typescript" + path.sep + "src" + path.sep + "index.html",
140
- to: "index.html",
141
- toFolder: "src" + path.sep + "pages",
142
- });
143
- if (packageJson.unit.trim() === "yes") {
144
- resources.push({
145
- from: "typescript" + path.sep + "test" + path.sep + "unit" + path.sep + "index.test.ts",
146
- to: "index.test.ts",
147
- toFolder: "test" + path.sep + "unit",
148
- });
149
- }
150
- if (packageJson.e2e.trim() === "yes") {
151
- resources.push({
152
- from: "typescript" + path.sep + "test" + path.sep + "e2e" + path.sep + "frontpage.test.ts",
153
- to: "frontpage.test.ts",
154
- toFolder: "test" + path.sep + "e2e",
155
- });
156
- resources.push({
157
- from: "typescript" + path.sep + "test" + path.sep + "e2e-config.ts",
158
- to: "e2e-config.ts",
159
- toFolder: "test",
160
- });
161
- resources.push({
162
- from: "typescript" + path.sep + "test" + path.sep + "e2e-key.config",
163
- to: "e2e-key.config",
164
- toFolder: "test",
165
- });
166
- }
167
- for (const res of resources) {
168
- let from, to, toFolder = "";
169
- if (typeof res === "string") {
170
- from = to = res;
171
- }
172
- else {
173
- from = res.from;
174
- to = res.to;
175
- toFolder = res.toFolder || "";
176
- }
177
- let content = fs.readFileSync(path.resolve(__dirname, "..", "..", "..", "..", "resources", "new-app", from)).toString();
178
- if (toFolder) {
179
- file_utils_1.FileUtils.createDirRecurSync(path.resolve(packageJson.name, toFolder));
180
- }
181
- if (from.endsWith("index.ts")) {
182
- content = content.replace("{NAMESPACE}", packageJson.namespace)
183
- .replace("{NAME}", packageJson.name)
184
- .replace("{PAGE_NAME}", packageJson.namespace + "." + packageJson.name);
185
- }
186
- fs.writeFileSync(path.resolve(packageJson.name, toFolder, to), content);
187
- }
188
- }
189
- }
190
- exports.NewCommand = NewCommand;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NewCommand = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const prompt = require("prompt");
8
+ const file_utils_1 = require("../../../file-utils");
9
+ const logger_1 = require("../../../logger");
10
+ const download_1 = require("../scifeon/download");
11
+ class NewCommand {
12
+ constructor() {
13
+ prompt.message = "";
14
+ prompt.delimiter = ":";
15
+ }
16
+ execute() {
17
+ prompt.start();
18
+ const packageJson = {
19
+ properties: {
20
+ name: {
21
+ description: "Name (used for directory name, e.g. 'science_app')",
22
+ pattern: /^[a-zA-Z\_]+$/,
23
+ message: "Name must be only letters and underscores (_)",
24
+ required: true,
25
+ },
26
+ displayName: {
27
+ description: "Display Name (used in Administration interface, e.g. 'Awesome Scifeon App'. If empty, name is used)",
28
+ },
29
+ namespace: {
30
+ description: "Namespace (e.g. 'com.scifeon')",
31
+ required: true,
32
+ pattern: /^[a-zA-Z\.]+$/,
33
+ message: "Namespace must be only letters and dots",
34
+ },
35
+ author: {
36
+ description: "Author (e.g. 'Demo Inc.')",
37
+ required: true,
38
+ message: "Author must not be empty",
39
+ },
40
+ description: {
41
+ description: "Description",
42
+ required: true,
43
+ message: "Description must not be empty",
44
+ },
45
+ editor: {
46
+ description: "Editor (vscode or none)",
47
+ default: "vscode",
48
+ },
49
+ unit: {
50
+ description: "Include Unit tests (yes or no)",
51
+ default: "yes",
52
+ },
53
+ e2e: {
54
+ description: "Include E2E tests (yes or no)",
55
+ default: "yes",
56
+ },
57
+ },
58
+ };
59
+ prompt.get(packageJson, (err, result) => this.parseResult(err, result));
60
+ }
61
+ parseResult(err, packageJson) {
62
+ if (err) {
63
+ return;
64
+ }
65
+ if (fs.existsSync(packageJson.name)) {
66
+ throw new Error("A folder with the name '" + packageJson.name + "' already exists.");
67
+ }
68
+ fs.mkdirSync(packageJson.name);
69
+ packageJson.version = "0.0.1";
70
+ packageJson.scifeon = {};
71
+ if (!packageJson.displayName) {
72
+ packageJson.name = packageJson.displayName;
73
+ }
74
+ const cliPackageJson = require(path.resolve(__dirname, "..", "..", "..", "..", "package.json"));
75
+ packageJson.scifeon.cliVersion = cliPackageJson.version;
76
+ packageJson.dependencies = {
77
+ "aurelia-bootstrapper": cliPackageJson.dependencies["aurelia-bootstrapper"],
78
+ };
79
+ packageJson.devDependencies = {
80
+ "@scifeon/sdk": "^" + packageJson.scifeon.cliVersion,
81
+ "tslib": cliPackageJson.dependencies.tslib,
82
+ };
83
+ if (packageJson.e2e.trim() === "yes") {
84
+ packageJson.devDependencies["@scifeon/e2e-test"] = "^0.33.0";
85
+ }
86
+ if (packageJson.e2e.trim() === "yes" || packageJson.unit.trim() === "yes") {
87
+ packageJson.devDependencies["@types/chai"] = cliPackageJson.dependencies["@types/chai"];
88
+ packageJson.devDependencies["@types/mocha"] = cliPackageJson.dependencies["@types/mocha"];
89
+ }
90
+ const contributionsJson = {
91
+ menu: {
92
+ main: [{
93
+ text: "Custom Page: " + packageJson.namespace + "." + packageJson.name,
94
+ route: "app/" + packageJson.namespace + "/" + packageJson.name,
95
+ }],
96
+ },
97
+ };
98
+ this.copyResources(packageJson);
99
+ delete packageJson.e2e;
100
+ delete packageJson.unit;
101
+ new download_1.DownloadCommand().execute(packageJson.name)
102
+ .then(() => {
103
+ const versionFile = path.resolve(packageJson.name, "runtime", "scifeon", "VERSION");
104
+ packageJson.scifeon.runtimeVersion = fs.readFileSync(versionFile).toString();
105
+ fs.writeFileSync(path.resolve(packageJson.name, "package.json"), JSON.stringify(packageJson, null, 2));
106
+ fs.writeFileSync(path.resolve(packageJson.name, "contributions.json"), JSON.stringify(contributionsJson, null, 2));
107
+ logger_1.LOGGER.msg("Installing node_modules...");
108
+ const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
109
+ const proc = (0, child_process_1.spawn)(npmCmd, ["install --silent --prefer-offline --no-audit"], { cwd: path.resolve(packageJson.name) });
110
+ proc.stderr.on("data", (data) => console.log(data.toString()));
111
+ proc.stdout.on("data", (data) => console.log(data.toString()));
112
+ proc.once("exit", () => logger_1.LOGGER.msg("App created in folder [" + packageJson.name + "]. Run 'scifeon-cli debug' in this directory to start development of your app."));
113
+ });
114
+ }
115
+ copyResources(packageJson) {
116
+ const resources = ["README.md"];
117
+ resources.push({
118
+ from: "gitignore.txt",
119
+ to: ".gitignore",
120
+ });
121
+ if (packageJson.editor.toLowerCase().trim() === "vscode") {
122
+ resources.push({
123
+ from: "editor" + path.sep + ".vscode" + path.sep + "launch.json",
124
+ to: "launch.json",
125
+ toFolder: ".vscode",
126
+ });
127
+ }
128
+ delete packageJson.editor;
129
+ resources.push({
130
+ from: "typescript" + path.sep + "tsconfig.json",
131
+ to: "tsconfig.json",
132
+ });
133
+ resources.push({
134
+ from: "typescript" + path.sep + "src" + path.sep + "index.ts",
135
+ to: "index.ts",
136
+ toFolder: "src" + path.sep + "pages",
137
+ });
138
+ resources.push({
139
+ from: "typescript" + path.sep + "src" + path.sep + "index.html",
140
+ to: "index.html",
141
+ toFolder: "src" + path.sep + "pages",
142
+ });
143
+ if (packageJson.unit.trim() === "yes") {
144
+ resources.push({
145
+ from: "typescript" + path.sep + "test" + path.sep + "unit" + path.sep + "index.test.ts",
146
+ to: "index.test.ts",
147
+ toFolder: "test" + path.sep + "unit",
148
+ });
149
+ }
150
+ if (packageJson.e2e.trim() === "yes") {
151
+ resources.push({
152
+ from: "typescript" + path.sep + "test" + path.sep + "e2e" + path.sep + "frontpage.test.ts",
153
+ to: "frontpage.test.ts",
154
+ toFolder: "test" + path.sep + "e2e",
155
+ });
156
+ resources.push({
157
+ from: "typescript" + path.sep + "test" + path.sep + "e2e-config.ts",
158
+ to: "e2e-config.ts",
159
+ toFolder: "test",
160
+ });
161
+ resources.push({
162
+ from: "typescript" + path.sep + "test" + path.sep + "e2e-key.config",
163
+ to: "e2e-key.config",
164
+ toFolder: "test",
165
+ });
166
+ }
167
+ for (const res of resources) {
168
+ let from, to, toFolder = "";
169
+ if (typeof res === "string") {
170
+ from = to = res;
171
+ }
172
+ else {
173
+ from = res.from;
174
+ to = res.to;
175
+ toFolder = res.toFolder || "";
176
+ }
177
+ let content = fs.readFileSync(path.resolve(__dirname, "..", "..", "..", "..", "resources", "new-app", from)).toString();
178
+ if (toFolder) {
179
+ file_utils_1.FileUtils.createDirRecurSync(path.resolve(packageJson.name, toFolder));
180
+ }
181
+ if (from.endsWith("index.ts")) {
182
+ content = content.replace("{NAMESPACE}", packageJson.namespace)
183
+ .replace("{NAME}", packageJson.name)
184
+ .replace("{PAGE_NAME}", packageJson.namespace + "." + packageJson.name);
185
+ }
186
+ fs.writeFileSync(path.resolve(packageJson.name, toFolder, to), content);
187
+ }
188
+ }
189
+ }
190
+ exports.NewCommand = NewCommand;
@@ -1,3 +1,3 @@
1
- export declare class PackageCommand {
2
- execute(): void;
3
- }
1
+ export declare class PackageCommand {
2
+ execute(): void;
3
+ }