@wiztivi/dana-cli 0.0.1 → 0.0.2

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 (113) hide show
  1. package/bin/dana.js +3 -0
  2. package/dana_completion.sh +153 -0
  3. package/dist/commands/add-device.d.ts +2 -0
  4. package/dist/commands/add-device.js +126 -0
  5. package/dist/commands/add-menu.d.ts +7 -0
  6. package/dist/commands/add-menu.js +51 -0
  7. package/dist/commands/add-rail.d.ts +10 -0
  8. package/dist/commands/add-rail.js +48 -0
  9. package/dist/commands/add-screen.d.ts +5 -0
  10. package/dist/commands/add-screen.js +71 -0
  11. package/dist/commands/add-scrollView.d.ts +7 -0
  12. package/dist/commands/add-scrollView.js +37 -0
  13. package/dist/commands/auth/login.d.ts +5 -0
  14. package/dist/commands/auth/login.js +141 -0
  15. package/dist/commands/auth/status.d.ts +11 -0
  16. package/dist/commands/auth/status.js +76 -0
  17. package/dist/commands/commandDefinitions/addDeviceDefinition.d.ts +3 -0
  18. package/dist/commands/commandDefinitions/addDeviceDefinition.js +16 -0
  19. package/dist/commands/commandDefinitions/addMenuDefinition.d.ts +3 -0
  20. package/dist/commands/commandDefinitions/addMenuDefinition.js +21 -0
  21. package/dist/commands/commandDefinitions/addRailDefinition.d.ts +3 -0
  22. package/dist/commands/commandDefinitions/addRailDefinition.js +31 -0
  23. package/dist/commands/commandDefinitions/addScreenDefinition.d.ts +3 -0
  24. package/dist/commands/commandDefinitions/addScreenDefinition.js +18 -0
  25. package/dist/commands/commandDefinitions/addScrollViewDefinition.d.ts +3 -0
  26. package/dist/commands/commandDefinitions/addScrollViewDefinition.js +18 -0
  27. package/dist/commands/commandDefinitions/authDefinition.d.ts +3 -0
  28. package/dist/commands/commandDefinitions/authDefinition.js +23 -0
  29. package/dist/commands/commandDefinitions/completionDefinition.d.ts +3 -0
  30. package/dist/commands/commandDefinitions/completionDefinition.js +17 -0
  31. package/dist/commands/commandDefinitions/createAppDefinition.d.ts +3 -0
  32. package/dist/commands/commandDefinitions/createAppDefinition.js +22 -0
  33. package/dist/commands/completion.d.ts +2 -0
  34. package/dist/commands/completion.js +84 -0
  35. package/dist/commands/createApp.d.ts +6 -0
  36. package/dist/commands/createApp.js +130 -0
  37. package/dist/commands/createComponent.d.ts +3 -0
  38. package/dist/commands/createComponent.js +81 -0
  39. package/dist/commands/help/customHelp.d.ts +3 -0
  40. package/dist/commands/help/customHelp.js +31 -0
  41. package/dist/commands/hooks/authHook.d.ts +1 -0
  42. package/dist/commands/hooks/authHook.js +23 -0
  43. package/dist/configs/ComponentConfig.d.ts +32 -0
  44. package/dist/configs/ComponentConfig.js +178 -0
  45. package/dist/configs/deviceConfig/androidtvConfig.d.ts +37 -0
  46. package/dist/configs/deviceConfig/androidtvConfig.js +186 -0
  47. package/dist/configs/deviceConfig/deviceConfig.d.ts +14 -0
  48. package/dist/configs/deviceConfig/deviceConfig.js +35 -0
  49. package/dist/configs/deviceConfig/tizenConfig.d.ts +31 -0
  50. package/dist/configs/deviceConfig/tizenConfig.js +56 -0
  51. package/dist/configs/deviceConfig/tvosConfig.d.ts +13 -0
  52. package/dist/configs/deviceConfig/tvosConfig.js +32 -0
  53. package/dist/configs/deviceConfig/webosConfig.d.ts +59 -0
  54. package/dist/configs/deviceConfig/webosConfig.js +179 -0
  55. package/dist/const/authentConst.d.ts +3 -0
  56. package/dist/const/authentConst.js +6 -0
  57. package/dist/const/componentConst.d.ts +8 -0
  58. package/dist/const/componentConst.js +22 -0
  59. package/dist/const/createApp/deviceConst.d.ts +23 -0
  60. package/dist/const/createApp/deviceConst.js +73 -0
  61. package/dist/const/createApp/setupConst.d.ts +3 -0
  62. package/dist/const/createApp/setupConst.js +18 -0
  63. package/dist/const/defaultConfig.d.ts +4 -0
  64. package/dist/const/defaultConfig.js +27 -0
  65. package/dist/const/exitCodeConst.d.ts +7 -0
  66. package/dist/const/exitCodeConst.js +10 -0
  67. package/dist/const/navigationConst.d.ts +3 -0
  68. package/dist/const/navigationConst.js +36 -0
  69. package/dist/dana_completion.sh +153 -0
  70. package/dist/helpers/CliHelper.d.ts +13 -0
  71. package/dist/helpers/CliHelper.js +39 -0
  72. package/dist/helpers/CodeArtifactHelper.d.ts +12 -0
  73. package/dist/helpers/CodeArtifactHelper.js +52 -0
  74. package/dist/helpers/ComponentHelper.d.ts +12 -0
  75. package/dist/helpers/ComponentHelper.js +105 -0
  76. package/dist/helpers/CredentialsHelper.d.ts +27 -0
  77. package/dist/helpers/CredentialsHelper.js +22 -0
  78. package/dist/helpers/createApp/CreateFileHelper.d.ts +31 -0
  79. package/dist/helpers/createApp/CreateFileHelper.js +84 -0
  80. package/dist/helpers/createApp/InputValidator.d.ts +5 -0
  81. package/dist/helpers/createApp/InputValidator.js +60 -0
  82. package/dist/helpers/createApp/InstallHelper.d.ts +30 -0
  83. package/dist/helpers/createApp/InstallHelper.js +112 -0
  84. package/dist/helpers/createApp/ScriptHelper.d.ts +116 -0
  85. package/dist/helpers/createApp/ScriptHelper.js +142 -0
  86. package/dist/helpers/createApp/SetupChecker.d.ts +25 -0
  87. package/dist/helpers/createApp/SetupChecker.js +128 -0
  88. package/dist/helpers/createApp/UpdateFileHelper.d.ts +40 -0
  89. package/dist/helpers/createApp/UpdateFileHelper.js +121 -0
  90. package/dist/helpers/createApp/UserInputGetter.d.ts +49 -0
  91. package/dist/helpers/createApp/UserInputGetter.js +145 -0
  92. package/dist/helpers/handlebarsHelper.d.ts +2 -0
  93. package/dist/helpers/handlebarsHelper.js +26 -0
  94. package/dist/helpers/stringHelper.d.ts +3 -0
  95. package/dist/helpers/stringHelper.js +11 -0
  96. package/dist/index.d.ts +2 -0
  97. package/dist/index.js +16 -0
  98. package/dist/program.d.ts +2 -0
  99. package/dist/program.js +42 -0
  100. package/dist/translation/en.json +62 -0
  101. package/dist/translation/translation.d.ts +2 -0
  102. package/dist/translation/translation.js +8 -0
  103. package/dist/types/componentTypes.d.ts +31 -0
  104. package/dist/types/componentTypes.js +2 -0
  105. package/dist/types/createApp/configTypes.d.ts +27 -0
  106. package/dist/types/createApp/configTypes.js +13 -0
  107. package/dist/types/createApp/helperTypes.d.ts +35 -0
  108. package/dist/types/createApp/helperTypes.js +14 -0
  109. package/dist/types/genericTypes.d.ts +17 -0
  110. package/dist/types/genericTypes.js +2 -0
  111. package/package.json +41 -22
  112. package/README.md +0 -5
  113. package/index.js +0 -1
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
4
+ * All Rights Reserved
5
+ *
6
+ * All information contained herein is proprietary and confidential.
7
+ * Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
8
+ * prior written permission is obtained from Wiztivi.
9
+ * No warranty, explicit or implicit, provided.
10
+ * This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
11
+ *
12
+ */
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __importDefault = (this && this.__importDefault) || function (mod) {
47
+ return (mod && mod.__esModule) ? mod : { "default": mod };
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ const prompts = __importStar(require("@clack/prompts"));
51
+ const picocolors_1 = __importDefault(require("picocolors"));
52
+ const child_process_1 = require("child_process");
53
+ const translation_1 = __importDefault(require("../../translation/translation"));
54
+ const exitCodeConst_1 = require("../../const/exitCodeConst");
55
+ class SetupChecker {
56
+ static checkSetup = async () => {
57
+ try {
58
+ await this.executeCheck([
59
+ {
60
+ title: "Node version validation",
61
+ task: async () => this.validateNodeVersion(),
62
+ },
63
+ {
64
+ title: "Git install validation",
65
+ task: async () => this.validateGitInstallation(),
66
+ },
67
+ {
68
+ title: "AWS install validation",
69
+ task: async () => this.validateAwsInstallation(),
70
+ },
71
+ ]);
72
+ prompts.log.success(picocolors_1.default.green("✔ ") + translation_1.default["setup.ok"]);
73
+ }
74
+ catch (error) {
75
+ prompts.outro(`${picocolors_1.default.red(translation_1.default["setup.ko"])}: ${error.message ?? ""}`);
76
+ process.exit(exitCodeConst_1.SETUP_ERROR);
77
+ }
78
+ };
79
+ /**
80
+ * Iterate on a list of setup tasks
81
+ * @param {Array} tasks
82
+ */
83
+ static async executeCheck(tasks) {
84
+ for (const item of tasks) {
85
+ await item.task();
86
+ }
87
+ }
88
+ /**
89
+ * Check if everything is set up correctly for the installation
90
+ * @returns {Promise}
91
+ */
92
+ static async validateNodeVersion() {
93
+ const minimalNodeVersion = 20;
94
+ const currentVersion = parseInt(process.version.slice(1).split(".")[0], 10);
95
+ return currentVersion >= minimalNodeVersion
96
+ ? Promise.resolve("Node version ok !")
97
+ : Promise.reject(new Error(`${translation_1.default["node.error"]} ${minimalNodeVersion}`));
98
+ }
99
+ /**
100
+ * Check if git cli is installed
101
+ * @returns {Promise<String>}
102
+ */
103
+ static async validateGitInstallation() {
104
+ return new Promise((resolve, reject) => {
105
+ (0, child_process_1.exec)("git --version", {}, (error) => {
106
+ if (error != null) {
107
+ reject(new Error(translation_1.default["git.error"]));
108
+ }
109
+ resolve("Git installation ok !");
110
+ });
111
+ });
112
+ }
113
+ /**
114
+ * Check if aws cli is installed
115
+ * @returns {Promise<String>}
116
+ */
117
+ static async validateAwsInstallation() {
118
+ return new Promise((resolve, reject) => {
119
+ (0, child_process_1.exec)("aws --version", {}, (error) => {
120
+ if (error != null) {
121
+ reject(new Error(translation_1.default["aws.cli.error"]));
122
+ }
123
+ resolve("AWS installation ok !");
124
+ });
125
+ });
126
+ }
127
+ }
128
+ exports.default = SetupChecker;
@@ -0,0 +1,40 @@
1
+ import { Config } from "../../types/createApp/helperTypes";
2
+ declare class UpdateFileHelper {
3
+ /**
4
+ * Update app.Config files with mandatory Data
5
+ * @returns {Promise}
6
+ */
7
+ static readonly updateAppConfigFile: ({ directory }: {
8
+ directory: string;
9
+ }) => Promise<string>;
10
+ /**
11
+ * Update .npmrc with proper registry key
12
+ */
13
+ static readonly updateNpmrcFile: ({ directory }: {
14
+ directory: string;
15
+ }) => Promise<string>;
16
+ /**
17
+ * Update package.json with the right project name and add scripts if necessary
18
+ */
19
+ static readonly updatePackageJson: ({ name, directory, selectedDevices, config, }: {
20
+ name: string;
21
+ directory: string;
22
+ selectedDevices: string[];
23
+ config: Config;
24
+ }) => Promise<string>;
25
+ /**
26
+ * set specific configuration for selected devices
27
+ */
28
+ static readonly setDevicesConfig: ({ directory, config, selectedDevices, awsProfile, }: {
29
+ directory: string;
30
+ config: Config;
31
+ selectedDevices: string[];
32
+ awsProfile: string;
33
+ }) => Promise<string>;
34
+ static readonly setScriptValue: (value: string) => string;
35
+ static readonly applyTemplatesToFiles: ({ directory, name, }: {
36
+ directory: string;
37
+ name: string;
38
+ }) => Promise<string>;
39
+ }
40
+ export default UpdateFileHelper;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
4
+ * All Rights Reserved
5
+ *
6
+ * All information contained herein is proprietary and confidential.
7
+ * Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
8
+ * prior written permission is obtained from Wiztivi.
9
+ * No warranty, explicit or implicit, provided.
10
+ * This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
11
+ *
12
+ */
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const path_1 = __importDefault(require("path"));
19
+ const ScriptHelper_1 = __importDefault(require("../../helpers/createApp/ScriptHelper"));
20
+ const handlebarsHelper_1 = require("../../helpers/handlebarsHelper");
21
+ const CredentialsHelper_1 = require("../CredentialsHelper");
22
+ const CodeArtifactHelper_1 = require("../CodeArtifactHelper");
23
+ class UpdateFileHelper {
24
+ /**
25
+ * Update app.Config files with mandatory Data
26
+ * @returns {Promise}
27
+ */
28
+ static updateAppConfigFile = function ({ directory }) {
29
+ const dirPath = path_1.default.join(directory, "profiles");
30
+ const filePath = path_1.default.join(directory, "app.config.json");
31
+ const profileList = fs_1.default
32
+ .readdirSync(dirPath, { withFileTypes: true })
33
+ .filter((item) => !item.isDirectory())
34
+ .map((item) => path_1.default.join("profiles", item.name));
35
+ const jsonData = JSON.parse(fs_1.default.readFileSync(filePath).toString());
36
+ jsonData.includes = profileList;
37
+ fs_1.default.writeFileSync(filePath, JSON.stringify(jsonData, null, 4));
38
+ return Promise.resolve("Config file(s) updated");
39
+ };
40
+ /**
41
+ * Update .npmrc with proper registry key
42
+ */
43
+ static updateNpmrcFile = async function ({ directory }) {
44
+ const credentials = CredentialsHelper_1.CredentialsHelper.get();
45
+ const registryAccount = await (0, CodeArtifactHelper_1.getRepositoryEndpoint)({
46
+ organization: credentials.org,
47
+ credentials: credentials?.aws,
48
+ format: "npm",
49
+ });
50
+ const filePath = path_1.default.join(directory, ".npmrc");
51
+ fs_1.default.writeFileSync(filePath, registryAccount);
52
+ return Promise.resolve("AWS profile updated");
53
+ };
54
+ /**
55
+ * Update package.json with the right project name and add scripts if necessary
56
+ */
57
+ static updatePackageJson = ({ name, directory, selectedDevices, config, }) => {
58
+ const filePath = path_1.default.join(directory, "package.json");
59
+ const packageJson = JSON.parse(fs_1.default.readFileSync(filePath).toString());
60
+ packageJson.name = name;
61
+ for (const device of selectedDevices) {
62
+ const deviceConfig = config[device];
63
+ if (deviceConfig?.renderers) {
64
+ deviceConfig.renderers.forEach((renderer) => {
65
+ const profileName = `${device}_${renderer}`;
66
+ packageJson.scripts[`start:${profileName}`] = this.setScriptValue(profileName);
67
+ });
68
+ }
69
+ else {
70
+ packageJson.scripts[`start:${device}`] = this.setScriptValue(device);
71
+ }
72
+ }
73
+ fs_1.default.writeFileSync(filePath, JSON.stringify(packageJson, null, 4));
74
+ return Promise.resolve("Package updated");
75
+ };
76
+ /**
77
+ * set specific configuration for selected devices
78
+ */
79
+ static setDevicesConfig = async function ({ directory, config, selectedDevices, awsProfile, }) {
80
+ for (const device of selectedDevices) {
81
+ const obj = config[device];
82
+ //@ts-expect-error @typescript-eslint/ban-ts-comment
83
+ await ScriptHelper_1.default.getDeviceConfig(device).setConfig({ directory, awsProfile, config: obj });
84
+ }
85
+ return Promise.resolve("Configuration done");
86
+ };
87
+ static setScriptValue = (value) => {
88
+ return `grunt serve --profile=template-${value}`;
89
+ };
90
+ static applyTemplatesToFiles = function ({ directory, name, }) {
91
+ const routesFilePath = path_1.default.join(directory, "scripts", "app");
92
+ const appName = `${name[0].toUpperCase()}${name.substring(1)}`;
93
+ const filesToUpdate = [
94
+ {
95
+ fromPath: path_1.default.join(routesFilePath, "TemplateAppRoutes.js.hbs"),
96
+ config: { appName },
97
+ toPath: path_1.default.join(routesFilePath, `${appName}AppRoutes.js`),
98
+ },
99
+ {
100
+ fromPath: path_1.default.join(routesFilePath, "app.js.hbs"),
101
+ config: { appName },
102
+ toPath: path_1.default.join(routesFilePath, "app.js"),
103
+ },
104
+ {
105
+ fromPath: path_1.default.join(directory, "tests", "unit", "app", "TemplateAppRoutes.js.hbs"),
106
+ config: { appName },
107
+ toPath: path_1.default.join(directory, "tests", "unit", "app", `${appName}AppRoutes.js`),
108
+ },
109
+ ];
110
+ filesToUpdate.forEach((file) => {
111
+ const updatedContent = (0, handlebarsHelper_1.templateGenerator)(file.fromPath, file.config);
112
+ fs_1.default.writeFileSync(file.toPath, updatedContent);
113
+ fs_1.default.unlink(file.fromPath, (err) => {
114
+ if (err)
115
+ console.error(err);
116
+ });
117
+ });
118
+ return Promise.resolve("Files templated");
119
+ };
120
+ }
121
+ exports.default = UpdateFileHelper;
@@ -0,0 +1,49 @@
1
+ import { Config } from "../../types/createApp/helperTypes";
2
+ type SelectionArray = {
3
+ value: string;
4
+ label: string;
5
+ }[];
6
+ interface DataResults {
7
+ name: string;
8
+ }
9
+ declare class UserInputGetter {
10
+ /**
11
+ * Get project Data from user
12
+ */
13
+ static getPrompts(argsName: string, shouldAddDevices: boolean): {
14
+ name: () => Promise<string>;
15
+ directory: ({ results }: {
16
+ results: DataResults;
17
+ }) => Promise<string>;
18
+ selectedDevices: () => Promise<string[]>;
19
+ };
20
+ /**
21
+ * Ask the project name
22
+ */
23
+ static askProjectName(name?: string): Promise<string>;
24
+ static getProjectDirectory(projectName: string): Promise<string>;
25
+ /**
26
+ * Get a list of subscribed and non subscribed devices
27
+ */
28
+ static getAvailableDevices(): Promise<{
29
+ availableDevices: SelectionArray;
30
+ unavailableDevices: string[];
31
+ }>;
32
+ /**
33
+ * Ask for a list of devices
34
+ */
35
+ static askDevices(shouldAddDevices: boolean): Promise<string[]>;
36
+ /**
37
+ * Get devices natively included in user subscription
38
+ */
39
+ static getBasicDevices(): string[];
40
+ /**
41
+ * get specific configuration for selected devices
42
+ * @returns {Promise<any>}
43
+ */
44
+ static getDevicesConfig({ selectedDevices, awsProfile, }: {
45
+ selectedDevices: string[];
46
+ awsProfile: string;
47
+ }): Promise<Config>;
48
+ }
49
+ export default UserInputGetter;
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
4
+ * All Rights Reserved
5
+ *
6
+ * All information contained herein is proprietary and confidential.
7
+ * Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
8
+ * prior written permission is obtained from Wiztivi.
9
+ * No warranty, explicit or implicit, provided.
10
+ * This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
11
+ *
12
+ */
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __importDefault = (this && this.__importDefault) || function (mod) {
47
+ return (mod && mod.__esModule) ? mod : { "default": mod };
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ const prompts = __importStar(require("@clack/prompts"));
51
+ const child_process_1 = require("child_process");
52
+ const ScriptHelper_1 = __importDefault(require("./ScriptHelper"));
53
+ const deviceConst_1 = require("../../const/createApp/deviceConst");
54
+ const InputValidator_1 = require("./InputValidator");
55
+ const translation_1 = __importDefault(require("../../translation/translation"));
56
+ class UserInputGetter {
57
+ /**
58
+ * Get project Data from user
59
+ */
60
+ static getPrompts(argsName, shouldAddDevices) {
61
+ return {
62
+ name: () => this.askProjectName(argsName),
63
+ directory: ({ results }) => this.getProjectDirectory(results.name),
64
+ selectedDevices: () => this.askDevices(shouldAddDevices),
65
+ };
66
+ }
67
+ /**
68
+ * Ask the project name
69
+ */
70
+ static async askProjectName(name) {
71
+ if (name != null) {
72
+ return Promise.resolve(name);
73
+ }
74
+ const errorMessage = "Project name is mandatory !";
75
+ name = (await prompts.text({
76
+ message: translation_1.default["input.name"],
77
+ placeholder: "Placeholder Name",
78
+ validate: (value) => (0, InputValidator_1.validInputLength)(value, errorMessage),
79
+ }));
80
+ ScriptHelper_1.default.handleCancellation(name);
81
+ return name.trim();
82
+ }
83
+ static async getProjectDirectory(projectName) {
84
+ return Promise.resolve(`./${projectName}`);
85
+ }
86
+ /**
87
+ * Get a list of subscribed and non subscribed devices
88
+ */
89
+ static getAvailableDevices() {
90
+ const availableDevices = [];
91
+ const unavailableDevices = [];
92
+ for (const [key, value] of Object.entries(deviceConst_1.EXTENDED_SETUP)) {
93
+ try {
94
+ console.info(`npm view ${value.package} --silent`);
95
+ (0, child_process_1.execSync)(`npm view ${value.package} --silent`, { encoding: "utf-8" });
96
+ availableDevices.push({ value: key, label: deviceConst_1.EXTENDED_SETUP[key].label });
97
+ }
98
+ catch {
99
+ unavailableDevices.push(deviceConst_1.EXTENDED_SETUP[key].label);
100
+ }
101
+ }
102
+ return Promise.resolve({ availableDevices, unavailableDevices });
103
+ }
104
+ /**
105
+ * Ask for a list of devices
106
+ */
107
+ static async askDevices(shouldAddDevices) {
108
+ let selectedDevices = this.getBasicDevices();
109
+ if (!shouldAddDevices) {
110
+ return selectedDevices;
111
+ }
112
+ const { availableDevices, unavailableDevices } = await this.getAvailableDevices();
113
+ if (unavailableDevices.length) {
114
+ ScriptHelper_1.default.promptUnavailableDevices(unavailableDevices);
115
+ }
116
+ if (availableDevices.length) {
117
+ const selectObject = {
118
+ message: "Press space key to select additional device(s).",
119
+ options: availableDevices,
120
+ required: false,
121
+ };
122
+ selectedDevices = selectedDevices.concat((await prompts.multiselect(selectObject)));
123
+ }
124
+ ScriptHelper_1.default.handleCancellation(selectedDevices);
125
+ return selectedDevices;
126
+ }
127
+ /**
128
+ * Get devices natively included in user subscription
129
+ */
130
+ static getBasicDevices() {
131
+ return Object.keys(deviceConst_1.BASIC_SETUP);
132
+ }
133
+ /**
134
+ * get specific configuration for selected devices
135
+ * @returns {Promise<any>}
136
+ */
137
+ static async getDevicesConfig({ selectedDevices, awsProfile, }) {
138
+ const config = {};
139
+ for (const device of selectedDevices) {
140
+ config[device] = (await ScriptHelper_1.default.getDeviceConfig(device).getConfig(awsProfile));
141
+ }
142
+ return Promise.resolve(config);
143
+ }
144
+ }
145
+ exports.default = UserInputGetter;
@@ -0,0 +1,2 @@
1
+ declare function templateGenerator(templatePath: string, config: object): string;
2
+ export { templateGenerator };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.templateGenerator = templateGenerator;
7
+ const handlebars_1 = __importDefault(require("handlebars"));
8
+ const fs_1 = require("fs");
9
+ const stringHelper_1 = require("./stringHelper");
10
+ handlebars_1.default.registerHelper("ifEqTo", (arg1, arg2) => {
11
+ return arg1 === arg2;
12
+ });
13
+ handlebars_1.default.registerHelper("ifNotEqTo", (arg1, arg2) => {
14
+ return arg1 !== arg2;
15
+ });
16
+ handlebars_1.default.registerHelper("normalizeName", (arg1, arg2) => {
17
+ return `${(0, stringHelper_1.capitalizeFirstLetter)(arg1)}${arg2}`;
18
+ });
19
+ handlebars_1.default.registerHelper("capitalize", (arg1) => {
20
+ return (0, stringHelper_1.capitalizeFirstLetter)(arg1);
21
+ });
22
+ function templateGenerator(templatePath, config) {
23
+ const templateString = (0, fs_1.readFileSync)(templatePath, "utf-8");
24
+ const template = handlebars_1.default.compile(templateString);
25
+ return template(config);
26
+ }
@@ -0,0 +1,3 @@
1
+ import { OptionList } from "../types/genericTypes";
2
+ export declare const capitalizeFirstLetter: (input: string) => string;
3
+ export declare const optionsListString: (input: OptionList) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optionsListString = exports.capitalizeFirstLetter = void 0;
4
+ const capitalizeFirstLetter = (input) => {
5
+ return `${input[0].toUpperCase()}${input.substring(1)}`;
6
+ };
7
+ exports.capitalizeFirstLetter = capitalizeFirstLetter;
8
+ const optionsListString = (input) => {
9
+ return input.map((option) => option.command).join(", ");
10
+ };
11
+ exports.optionsListString = optionsListString;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /*
4
+ * Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
5
+ * All Rights Reserved
6
+ *
7
+ * All information contained herein is proprietary and confidential.
8
+ * Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
9
+ * prior written permission is obtained from Wiztivi.
10
+ * No warranty, explicit or implicit, provided.
11
+ * This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
12
+ *
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const program_1 = require("./program");
16
+ (0, program_1.makeProgram)().parse();
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const makeProgram: () => Command;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makeProgram = void 0;
7
+ const commander_1 = require("commander");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const addDeviceDefinition_1 = __importDefault(require("./commands/commandDefinitions/addDeviceDefinition"));
11
+ const addMenuDefinition_1 = __importDefault(require("./commands/commandDefinitions/addMenuDefinition"));
12
+ const addRailDefinition_1 = __importDefault(require("./commands/commandDefinitions/addRailDefinition"));
13
+ const addScreenDefinition_1 = __importDefault(require("./commands/commandDefinitions/addScreenDefinition"));
14
+ const addScrollViewDefinition_1 = __importDefault(require("./commands/commandDefinitions/addScrollViewDefinition"));
15
+ const authDefinition_1 = __importDefault(require("./commands/commandDefinitions/authDefinition"));
16
+ const customHelp_1 = __importDefault(require("./commands/help/customHelp"));
17
+ const translation_1 = __importDefault(require("./translation/translation"));
18
+ const createAppDefinition_1 = __importDefault(require("./commands/commandDefinitions/createAppDefinition"));
19
+ const completionDefinition_1 = __importDefault(require("./commands/commandDefinitions/completionDefinition"));
20
+ const makeProgram = () => {
21
+ const filePath = path_1.default.join(__dirname, "..", "package.json");
22
+ const packageJson = JSON.parse(fs_1.default.readFileSync(filePath, { encoding: "utf-8" }));
23
+ const program = new commander_1.Command(packageJson.name);
24
+ program
25
+ .usage(`${translation_1.default["program.usage"]}`)
26
+ .version(packageJson.version)
27
+ .addCommand((0, addRailDefinition_1.default)())
28
+ .addCommand((0, addDeviceDefinition_1.default)())
29
+ .addCommand((0, addMenuDefinition_1.default)())
30
+ .addCommand((0, authDefinition_1.default)())
31
+ .addCommand((0, addScrollViewDefinition_1.default)())
32
+ .addCommand((0, addScreenDefinition_1.default)())
33
+ .addCommand((0, createAppDefinition_1.default)())
34
+ .addCommand((0, completionDefinition_1.default)());
35
+ //help
36
+ program.helpInformation = () => (0, customHelp_1.default)(program);
37
+ program.addHelpText("afterAll", `
38
+ ${translation_1.default["program.help.footer"]}
39
+ `);
40
+ return program;
41
+ };
42
+ exports.makeProgram = makeProgram;
@@ -0,0 +1,62 @@
1
+ {
2
+ "program.usage": "A CLI to help you build dana applications",
3
+ "program.help.footer": "For more information, visit https://doc.dana-framework.com or contact us.",
4
+ "component.creation.success": "component created successfully.",
5
+ "component.creation.error": "Failed to create component",
6
+ "command.rail.description": "Add a rail",
7
+ "command.component.name": "Component's name",
8
+ "command.component.customization": "Full or partial customization. MANDATORY to not use default configuration.",
9
+ "command.rail.option.navigation": "Navigation type. Default: fixed",
10
+ "command.rail.option.direction": "Navigation direction. Default: horizontal",
11
+ "command.rail.option.cyclic": "True if cyclic. Default: false",
12
+ "command.device.description": "Add device(s) to your Dana app",
13
+ "command.device.version.error": "No version found.",
14
+ "command.device.no_selection": "Nothing selected or no device available. Exit",
15
+ "help.custom.devices": "Use the CLI to add the following devices:",
16
+ "help.custom.commands": "Add devices and built-in components to your DANA app:",
17
+ "help.option.title": "Available command options:",
18
+ "help.option.check": "check:",
19
+ "command.menu.description": "Add horizontal menu",
20
+ "command.menu.option.itemView": "Item to be used in the menu",
21
+ "command.menu.option.itemMargin": "Margin between items. Default: 20",
22
+ "helper.git.status.error": "Git status is not clean or an error occurred. Try to commit your change.",
23
+ "command.auth.description": "Authenticate to Dana framework",
24
+ "command.auth.login.description": "Login to Dana",
25
+ "command.auth.login.option.org": "Organization to login",
26
+ "command.auth.status.description": "Get login status",
27
+ "command.scrollView.description": "Add a scrollView of rails",
28
+ "command.scrollView.option.itemView": "Item to be used in the scrollView. Default: pre-made rail",
29
+ "command.scrollView.option.itemMargin": "Margin between items. Default: 550",
30
+ "command.screen.description": "Add a screen",
31
+ "command.create_app.description": "Create a new Dana app",
32
+ "command.create_app.name": "Project's name",
33
+ "command.create_app.directory": "Project directory",
34
+ "command.create_app.tutorial": "Create project for tutorial",
35
+ "command.create_app.devices": "Add device(s) when creating the project",
36
+ "command.create_app.aws_profile": "Aws profile",
37
+ "command.create_app.aws_repository": "Aws repository provided during registration. Name is XXX in \"dana-XXX-repository\".",
38
+ "task.installation.start": "Installation",
39
+ "task.installation.end": "Installation complete.",
40
+ "creation.final": "Everything is ready.",
41
+ "script.run.title": "Now you can just run:",
42
+ "git.error": "Git is not installed or not available in the PATH. You must install it to continue.",
43
+ "aws.cli.error": "AWS cli is not installed or not available in the PATH. You must install it to continue.",
44
+ "node.error": "Node version should be >=",
45
+ "setup.ok": "Configuration ok",
46
+ "setup.ko": "Prerequisite not met",
47
+ "device.unavailable": "Enhance your experience by adding device(s) to your subscription:",
48
+ "device.selection": "Press space key to select additional device(s).",
49
+ "renderer.selection": "Select AT LEAST one renderer for",
50
+ "input.name": "What is your project's name ?",
51
+ "input.aws.error": "You need to have an AWS account.\nSee:https://dana-framework.com/guides/getting-started#configure-aws-connection",
52
+ "input.aws.profile": "Select your AWS profile",
53
+ "aws.login.error": "Please log to AWS before trying again",
54
+ "error.common.start.message": "An error occurred",
55
+ "command.completion.description": "Install shell completion (bash or zsh)",
56
+ "command.completion.argument": "Shell. Bash or zsh",
57
+ "command.completion.success": "Completion installed to ",
58
+ "login.info.token_expired": "Your token has expired.",
59
+ "login.info.please_login": "Please run dana auth login command",
60
+ "login.error.not_logged": "You're not logged in.",
61
+ "login.info.logged": "You're currently logged in to Dana"
62
+ }
@@ -0,0 +1,2 @@
1
+ declare const translation: Record<string, string>;
2
+ export default translation;