@wiztivi/dana-cli 0.0.2 → 0.0.6

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 (147) hide show
  1. package/bin/dana.js +1 -1
  2. package/dist/commands/addComponent/addMenu/add-menu.js +45 -0
  3. package/dist/commands/addComponent/addMenu/addMenuDefinition.js +16 -0
  4. package/dist/commands/addComponent/addRail/add-rail.js +42 -0
  5. package/dist/commands/addComponent/addRail/addRailDefinition.js +26 -0
  6. package/dist/commands/addComponent/addScreen/add-screen.js +33 -0
  7. package/dist/commands/addComponent/addScreen/addScreenDefinition.js +13 -0
  8. package/dist/commands/addComponent/addScrollView/add-scrollView.js +31 -0
  9. package/dist/commands/addComponent/addScrollView/addScrollViewDefinition.js +13 -0
  10. package/dist/{configs → commands/addComponent/config}/ComponentConfig.d.ts +2 -2
  11. package/dist/{configs → commands/addComponent/config}/ComponentConfig.js +25 -63
  12. package/dist/commands/addComponent/config/componentTypes.js +1 -0
  13. package/dist/commands/addComponent/const/componentConst.js +19 -0
  14. package/dist/{const → commands/addComponent/const}/defaultConfig.d.ts +1 -1
  15. package/dist/commands/addComponent/const/defaultConfig.js +24 -0
  16. package/dist/{const → commands/addComponent/const}/navigationConst.d.ts +1 -1
  17. package/dist/{const → commands/addComponent/const}/navigationConst.js +7 -13
  18. package/dist/commands/{createComponent.d.ts → addComponent/createComponent.d.ts} +1 -1
  19. package/dist/commands/addComponent/createComponent.js +41 -0
  20. package/dist/{helpers → commands/addComponent/helper}/ComponentHelper.d.ts +2 -1
  21. package/dist/commands/addComponent/helper/ComponentHelper.js +77 -0
  22. package/dist/commands/addDevice/add-device.js +88 -0
  23. package/dist/commands/addDevice/addDeviceDefinition.js +11 -0
  24. package/dist/{configs → commands/addDevice}/deviceConfig/androidtvConfig.d.ts +1 -1
  25. package/dist/commands/addDevice/deviceConfig/androidtvConfig.js +148 -0
  26. package/dist/{types/createApp → commands/addDevice/deviceConfig}/configTypes.js +1 -2
  27. package/dist/{configs → commands/addDevice}/deviceConfig/deviceConfig.js +3 -5
  28. package/dist/{configs → commands/addDevice}/deviceConfig/tizenConfig.d.ts +1 -1
  29. package/dist/{configs → commands/addDevice}/deviceConfig/tizenConfig.js +11 -16
  30. package/dist/commands/addDevice/deviceConfig/tvosConfig.js +27 -0
  31. package/dist/{configs → commands/addDevice}/deviceConfig/webosConfig.d.ts +2 -2
  32. package/dist/{configs → commands/addDevice}/deviceConfig/webosConfig.js +27 -66
  33. package/dist/{helpers/CliHelper.d.ts → commands/addDevice/helper/addDeviceHelper.d.ts} +2 -2
  34. package/dist/{helpers/CliHelper.js → commands/addDevice/helper/addDeviceHelper.js} +8 -13
  35. package/dist/commands/authentication/authDefinition.js +19 -0
  36. package/dist/commands/{hooks → authentication}/authHook.js +5 -9
  37. package/dist/{const → commands/authentication}/authentConst.d.ts +1 -0
  38. package/dist/commands/authentication/authentConst.js +4 -0
  39. package/dist/commands/authentication/commands/login.js +103 -0
  40. package/dist/commands/authentication/commands/status.js +36 -0
  41. package/dist/{helpers → commands/authentication/helper}/CodeArtifactHelper.d.ts +1 -1
  42. package/dist/commands/authentication/helper/CodeArtifactHelper.js +46 -0
  43. package/dist/commands/authentication/helper/CredentialsHelper.js +15 -0
  44. package/dist/commands/commandHelp/customHelp.js +26 -0
  45. package/dist/commands/completion/completion.js +48 -0
  46. package/dist/commands/completion/completionDefinition.js +12 -0
  47. package/dist/commands/createApp/const/setupConst.d.ts +3 -0
  48. package/dist/{const/createApp → commands/createApp/const}/setupConst.js +2 -6
  49. package/dist/commands/createApp/createApp.js +92 -0
  50. package/dist/commands/createApp/createAppDefinition.js +17 -0
  51. package/dist/{helpers/createApp/ScriptHelper.d.ts → commands/createApp/helpers/CreateAppHelper.d.ts} +15 -13
  52. package/dist/commands/createApp/helpers/CreateAppHelper.js +105 -0
  53. package/dist/{helpers/createApp → commands/createApp/helpers}/SetupChecker.d.ts +1 -1
  54. package/dist/commands/createApp/helpers/SetupChecker.js +90 -0
  55. package/dist/common/commonConst.d.ts +1 -0
  56. package/dist/common/commonConst.js +1 -0
  57. package/dist/{const/createApp → common/const}/deviceConst.js +1 -14
  58. package/dist/common/const/exitCodeConst.js +7 -0
  59. package/dist/{helpers/createApp → common/helpers}/CreateFileHelper.d.ts +1 -1
  60. package/dist/common/helpers/CreateFileHelper.js +79 -0
  61. package/dist/{helpers/createApp → common/helpers}/InputValidator.js +8 -16
  62. package/dist/{helpers/createApp → common/helpers}/InstallHelper.d.ts +1 -1
  63. package/dist/{helpers/createApp → common/helpers}/InstallHelper.js +20 -22
  64. package/dist/{helpers/createApp → common/helpers}/UpdateFileHelper.d.ts +1 -1
  65. package/dist/common/helpers/UpdateFileHelper.js +124 -0
  66. package/dist/{helpers/createApp → common/helpers}/UserInputGetter.d.ts +2 -1
  67. package/dist/common/helpers/UserInputGetter.js +115 -0
  68. package/dist/common/helpers/handlebarsHelper.js +21 -0
  69. package/dist/{helpers → common/helpers}/stringHelper.d.ts +1 -1
  70. package/dist/common/helpers/stringHelper.js +6 -0
  71. package/dist/common/translation/translation.js +3 -0
  72. package/dist/{types/createApp → common/types}/helperTypes.d.ts +17 -5
  73. package/dist/{types/createApp → common/types}/helperTypes.js +1 -3
  74. package/dist/index.js +2 -4
  75. package/dist/program.js +30 -35
  76. package/package.json +7 -4
  77. package/dist/commands/add-device.js +0 -126
  78. package/dist/commands/add-menu.js +0 -51
  79. package/dist/commands/add-rail.js +0 -48
  80. package/dist/commands/add-screen.js +0 -71
  81. package/dist/commands/add-scrollView.js +0 -37
  82. package/dist/commands/auth/login.js +0 -141
  83. package/dist/commands/auth/status.js +0 -76
  84. package/dist/commands/commandDefinitions/addDeviceDefinition.js +0 -16
  85. package/dist/commands/commandDefinitions/addMenuDefinition.js +0 -21
  86. package/dist/commands/commandDefinitions/addRailDefinition.js +0 -31
  87. package/dist/commands/commandDefinitions/addScreenDefinition.js +0 -18
  88. package/dist/commands/commandDefinitions/addScrollViewDefinition.js +0 -18
  89. package/dist/commands/commandDefinitions/authDefinition.js +0 -23
  90. package/dist/commands/commandDefinitions/completionDefinition.js +0 -17
  91. package/dist/commands/commandDefinitions/createAppDefinition.js +0 -22
  92. package/dist/commands/completion.js +0 -84
  93. package/dist/commands/createApp.js +0 -130
  94. package/dist/commands/createComponent.js +0 -81
  95. package/dist/commands/help/customHelp.js +0 -31
  96. package/dist/configs/deviceConfig/androidtvConfig.js +0 -186
  97. package/dist/configs/deviceConfig/tvosConfig.js +0 -32
  98. package/dist/const/authentConst.js +0 -6
  99. package/dist/const/componentConst.js +0 -22
  100. package/dist/const/createApp/setupConst.d.ts +0 -3
  101. package/dist/const/defaultConfig.js +0 -27
  102. package/dist/const/exitCodeConst.js +0 -10
  103. package/dist/helpers/CodeArtifactHelper.js +0 -52
  104. package/dist/helpers/ComponentHelper.js +0 -105
  105. package/dist/helpers/CredentialsHelper.js +0 -22
  106. package/dist/helpers/createApp/CreateFileHelper.js +0 -84
  107. package/dist/helpers/createApp/ScriptHelper.js +0 -142
  108. package/dist/helpers/createApp/SetupChecker.js +0 -128
  109. package/dist/helpers/createApp/UpdateFileHelper.js +0 -121
  110. package/dist/helpers/createApp/UserInputGetter.js +0 -145
  111. package/dist/helpers/handlebarsHelper.js +0 -26
  112. package/dist/helpers/stringHelper.js +0 -11
  113. package/dist/translation/translation.js +0 -8
  114. package/dist/types/componentTypes.js +0 -2
  115. package/dist/types/genericTypes.d.ts +0 -17
  116. package/dist/types/genericTypes.js +0 -2
  117. /package/dist/commands/{add-menu.d.ts → addComponent/addMenu/add-menu.d.ts} +0 -0
  118. /package/dist/commands/{commandDefinitions → addComponent/addMenu}/addMenuDefinition.d.ts +0 -0
  119. /package/dist/commands/{add-rail.d.ts → addComponent/addRail/add-rail.d.ts} +0 -0
  120. /package/dist/commands/{commandDefinitions → addComponent/addRail}/addRailDefinition.d.ts +0 -0
  121. /package/dist/commands/{add-screen.d.ts → addComponent/addScreen/add-screen.d.ts} +0 -0
  122. /package/dist/commands/{commandDefinitions → addComponent/addScreen}/addScreenDefinition.d.ts +0 -0
  123. /package/dist/commands/{add-scrollView.d.ts → addComponent/addScrollView/add-scrollView.d.ts} +0 -0
  124. /package/dist/commands/{commandDefinitions → addComponent/addScrollView}/addScrollViewDefinition.d.ts +0 -0
  125. /package/dist/{types → commands/addComponent/config}/componentTypes.d.ts +0 -0
  126. /package/dist/{const → commands/addComponent/const}/componentConst.d.ts +0 -0
  127. /package/dist/commands/{add-device.d.ts → addDevice/add-device.d.ts} +0 -0
  128. /package/dist/commands/{commandDefinitions → addDevice}/addDeviceDefinition.d.ts +0 -0
  129. /package/dist/{types/createApp → commands/addDevice/deviceConfig}/configTypes.d.ts +0 -0
  130. /package/dist/{configs → commands/addDevice}/deviceConfig/deviceConfig.d.ts +0 -0
  131. /package/dist/{configs → commands/addDevice}/deviceConfig/tvosConfig.d.ts +0 -0
  132. /package/dist/commands/{commandDefinitions → authentication}/authDefinition.d.ts +0 -0
  133. /package/dist/commands/{hooks → authentication}/authHook.d.ts +0 -0
  134. /package/dist/commands/{auth → authentication/commands}/login.d.ts +0 -0
  135. /package/dist/commands/{auth → authentication/commands}/status.d.ts +0 -0
  136. /package/dist/{helpers → commands/authentication/helper}/CredentialsHelper.d.ts +0 -0
  137. /package/dist/commands/{help → commandHelp}/customHelp.d.ts +0 -0
  138. /package/dist/commands/{completion.d.ts → completion/completion.d.ts} +0 -0
  139. /package/dist/commands/{commandDefinitions → completion}/completionDefinition.d.ts +0 -0
  140. /package/dist/commands/{createApp.d.ts → createApp/createApp.d.ts} +0 -0
  141. /package/dist/commands/{commandDefinitions → createApp}/createAppDefinition.d.ts +0 -0
  142. /package/dist/{const/createApp → common/const}/deviceConst.d.ts +0 -0
  143. /package/dist/{const → common/const}/exitCodeConst.d.ts +0 -0
  144. /package/dist/{helpers/createApp → common/helpers}/InputValidator.d.ts +0 -0
  145. /package/dist/{helpers → common/helpers}/handlebarsHelper.d.ts +0 -0
  146. /package/dist/{translation → common/translation}/en.json +0 -0
  147. /package/dist/{translation → common/translation}/translation.d.ts +0 -0
@@ -1,37 +0,0 @@
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
- const componentConst_1 = require("../const/componentConst");
7
- const createComponent_1 = __importDefault(require("./createComponent"));
8
- const node_process_1 = __importDefault(require("node:process"));
9
- const node_module_1 = require("node:module");
10
- const path_1 = __importDefault(require("path"));
11
- const fs_1 = require("fs");
12
- const defaultConfig_1 = require("../const/defaultConfig");
13
- const ComponentConfig_1 = __importDefault(require("../configs/ComponentConfig"));
14
- const addScrollView = async (name, options) => {
15
- const data = { ...options };
16
- if (name) {
17
- data.name = name;
18
- }
19
- const scrollViewConfig = {
20
- ...data,
21
- ...(await ComponentConfig_1.default.scrollViewConfig(data)),
22
- };
23
- const componentList = [scrollViewConfig];
24
- if (!data.custom) {
25
- componentList.push({ type: componentConst_1.SCROLL_ITEM, name: data.itemView ?? defaultConfig_1.SCROLLVIEW_DEFAULT_CONFIG.itemView }, { type: componentConst_1.TILE_VIEW, name: "mockTile" });
26
- }
27
- (0, createComponent_1.default)(componentList);
28
- if (!data.custom) {
29
- const currentDirectory = node_process_1.default.cwd();
30
- const require = (0, node_module_1.createRequire)(currentDirectory);
31
- const modulePath = require.resolve("@wiztivi/dana-templates");
32
- const mockPath = path_1.default.join(path_1.default.dirname(modulePath), "mocks", "scrollViewMock.json");
33
- const finalPath = path_1.default.resolve(currentDirectory, "scrollViewMock.json");
34
- (0, fs_1.cpSync)(mockPath, finalPath);
35
- }
36
- };
37
- exports.default = addScrollView;
@@ -1,141 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const client_codeartifact_1 = require("@aws-sdk/client-codeartifact");
40
- const prompts = __importStar(require("@clack/prompts"));
41
- const child_process_1 = require("child_process");
42
- const express_1 = __importDefault(require("express"));
43
- const get_port_1 = __importDefault(require("get-port"));
44
- const open_1 = __importDefault(require("open"));
45
- const picocolors_1 = __importDefault(require("picocolors"));
46
- const exitCodeConst_1 = require("../../const/exitCodeConst");
47
- const CredentialsHelper_1 = require("../../helpers/CredentialsHelper");
48
- const authentConst_1 = require("../../const/authentConst");
49
- const CodeArtifactHelper_1 = require("../../helpers/CodeArtifactHelper");
50
- /*
51
- Login to DANA backend (with aws and cognito) and connect to npm codeartifact
52
- More info: https://github.com/wiztivi-rd/dana-cli/wiki/Login
53
- */
54
- const login = async ({ org = "preprod" }) => {
55
- const apiUrl = `https://api.${org}.dana-framework.com`; // Or http://localhost:3001
56
- const credentials = CredentialsHelper_1.CredentialsHelper.get();
57
- if (credentials) {
58
- try {
59
- if (new Date(credentials.aws.expiration) < new Date()) {
60
- const data = await fetch(`${apiUrl}/login?refresh_token=${credentials.dana.refresh_token}`);
61
- if (!data.ok) {
62
- throw new Error("Unable to refresh token");
63
- }
64
- const refreshedCreds = (await data.json());
65
- credentials.aws = refreshedCreds.aws;
66
- credentials.dana = {
67
- ...refreshedCreds.token,
68
- refresh_token: credentials.dana.refresh_token,
69
- };
70
- CredentialsHelper_1.CredentialsHelper.store(credentials);
71
- }
72
- prompts.log.info(`Retrieved credentials for ${org} from local cache`);
73
- await codeartifactLogin(org, credentials.aws);
74
- return;
75
- }
76
- catch (error) {
77
- // Log message and start nominal login process
78
- prompts.log.error(error.message);
79
- }
80
- }
81
- prompts.intro(`Login to ${org}...`);
82
- try {
83
- const port = await (0, get_port_1.default)();
84
- const app = (0, express_1.default)();
85
- app.disable("x-powered-by");
86
- const server = app.listen(port);
87
- app.get("/callback", async (req, res) => {
88
- try {
89
- if (req.query.error) {
90
- throw new Error(req.query.error);
91
- }
92
- const token = JSON.parse(req.query.token);
93
- const awsCredentials = JSON.parse(req.query.aws);
94
- CredentialsHelper_1.CredentialsHelper.store({ aws: awsCredentials, dana: token, org });
95
- // Login to codeartifact repository
96
- await codeartifactLogin(org, awsCredentials);
97
- prompts.outro(picocolors_1.default.green("✓") + ` Login successfull`);
98
- res.send("Login successful! You can close this window.");
99
- }
100
- catch (err) {
101
- console.error(err);
102
- res.send("Login failed. Check the CLI for details.");
103
- handleError(err);
104
- }
105
- finally {
106
- server.close();
107
- }
108
- });
109
- await (0, open_1.default)(`${apiUrl}/login?port=${port}`);
110
- }
111
- catch (error) {
112
- console.error(error);
113
- handleError(error);
114
- }
115
- };
116
- const handleError = (error) => {
117
- const message = error instanceof Error ? error.message : error;
118
- prompts.outro(picocolors_1.default.red(`An issue occurred :` + message));
119
- process.exit(exitCodeConst_1.LOGIN_ERROR);
120
- };
121
- const codeartifactLogin = async (organization, credentials) => {
122
- // Create CodeArtifact client with credentials
123
- const client = (0, CodeArtifactHelper_1.createCodeArtifactClient)(credentials);
124
- // Get authorization token
125
- const tokenCommand = new client_codeartifact_1.GetAuthorizationTokenCommand({
126
- domain: authentConst_1.DOMAIN,
127
- domainOwner: authentConst_1.DOMAIN_OWNER,
128
- });
129
- const { authorizationToken, expiration } = await client.send(tokenCommand);
130
- if (!authorizationToken) {
131
- throw new Error("Authorization token not found");
132
- }
133
- // Get repository endpoint
134
- const repositoryEndpoint = await (0, CodeArtifactHelper_1.getRepositoryEndpoint)({ organization, credentials, client, format: "npm" });
135
- // Configure npm with the repository and token
136
- (0, child_process_1.execSync)(`npm config set @dana:registry=${repositoryEndpoint}`);
137
- (0, child_process_1.execSync)(`npm config set //${repositoryEndpoint.replace(/^https?:\/\//, "")}:_authToken=${authorizationToken}`);
138
- const expiresAt = expiration ? new Date(expiration).toLocaleString() : "unknown";
139
- prompts.log.step(`Successfully configured npm to use AWS CodeArtifact repository ${repositoryEndpoint}. \nLogin expires in 12 hours at: ${expiresAt}`);
140
- };
141
- exports.default = login;
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.statusAction = exports.status = exports.LOGIN_STATUS = void 0;
40
- const prompts = __importStar(require("@clack/prompts"));
41
- const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
42
- const picocolors_1 = __importDefault(require("picocolors"));
43
- const CredentialsHelper_1 = require("../../helpers/CredentialsHelper");
44
- const translation_1 = __importDefault(require("../../translation/translation"));
45
- var LOGIN_STATUS;
46
- (function (LOGIN_STATUS) {
47
- LOGIN_STATUS[LOGIN_STATUS["LOGGED"] = 1] = "LOGGED";
48
- LOGIN_STATUS[LOGIN_STATUS["NOT_LOGGED"] = 2] = "NOT_LOGGED";
49
- LOGIN_STATUS[LOGIN_STATUS["TOKEN_EXPIRED"] = 3] = "TOKEN_EXPIRED";
50
- })(LOGIN_STATUS || (exports.LOGIN_STATUS = LOGIN_STATUS = {}));
51
- const status = () => {
52
- const credentials = CredentialsHelper_1.CredentialsHelper.get();
53
- if (!credentials?.dana?.id_token) {
54
- prompts.log.error(`${translation_1.default["login.error.not_logged"]} ${translation_1.default["login.info.please_login"]}`);
55
- return LOGIN_STATUS.NOT_LOGGED;
56
- }
57
- const id_token = credentials.dana.id_token;
58
- const { given_name, family_name, email, exp } = jsonwebtoken_1.default.decode(id_token);
59
- const expiration = exp && new Date(exp * 1000);
60
- if (expiration && new Date() > expiration) {
61
- prompts.log.error(`${translation_1.default["login.info.token_expired"]} ${translation_1.default["login.info.please_login"]}`);
62
- return LOGIN_STATUS.TOKEN_EXPIRED;
63
- }
64
- const expStr = expiration ? `\nToken expires on ${expiration.toUTCString()}` : "";
65
- prompts.log.success(`${translation_1.default["login.info.logged"]} ${picocolors_1.default.bold(credentials.org)}: ${picocolors_1.default.bold(given_name + " " + family_name)} (${email})${expStr}
66
- `);
67
- return LOGIN_STATUS.LOGGED;
68
- };
69
- exports.status = status;
70
- /**
71
- * Sends void intentionally to be used a Commander acceptable command
72
- */
73
- const statusAction = () => {
74
- status();
75
- };
76
- exports.statusAction = statusAction;
@@ -1,16 +0,0 @@
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
- const commander_1 = require("commander");
7
- const add_device_1 = __importDefault(require("../add-device"));
8
- const translation_1 = __importDefault(require("../../translation/translation"));
9
- const authHook_1 = require("../hooks/authHook");
10
- const addDeviceDefinition = () => {
11
- return new commander_1.Command("add-device")
12
- .description(translation_1.default["command.device.description"])
13
- .hook("preAction", authHook_1.authHook)
14
- .action(add_device_1.default);
15
- };
16
- exports.default = addDeviceDefinition;
@@ -1,21 +0,0 @@
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
- const commander_1 = require("commander");
7
- const add_menu_1 = __importDefault(require("../add-menu"));
8
- const translation_1 = __importDefault(require("../../translation/translation"));
9
- const addMenuDefinition = () => {
10
- const command = new commander_1.Command("add-menu");
11
- command
12
- .description(translation_1.default["command.menu.description"])
13
- .argument("[name]", translation_1.default["command.component.name"])
14
- .option("-cm, --custom", translation_1.default["command.component.customization"])
15
- .option("-i, --itemView <itemView>", translation_1.default["command.menu.option.itemView"])
16
- .option("-m, --itemMargin <itemMargin>", translation_1.default["command.menu.option.itemMargin"])
17
- .option("-d, --direction <direction>", translation_1.default["command.rail.option.direction"])
18
- .action(add_menu_1.default);
19
- return command;
20
- };
21
- exports.default = addMenuDefinition;
@@ -1,31 +0,0 @@
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
- const commander_1 = require("commander");
7
- const add_rail_1 = __importDefault(require("../add-rail"));
8
- const navigationConst_1 = require("../../const/navigationConst");
9
- const translation_1 = __importDefault(require("../../translation/translation"));
10
- const stringHelper_1 = require("../../helpers/stringHelper");
11
- const addRailDefinition = () => {
12
- const command = new commander_1.Command("add-rail");
13
- command
14
- .description(translation_1.default["command.rail.description"])
15
- .argument("[name]", translation_1.default["command.component.name"])
16
- .option("-cm, --custom", translation_1.default["command.component.customization"])
17
- .option("-n, --navigation <navigation>", translation_1.default["command.rail.option.navigation"])
18
- .option("-d, --direction <direction>", translation_1.default["command.rail.option.direction"])
19
- .option("-c, --cyclic", translation_1.default["command.rail.option.cyclic"])
20
- .option("-i, --itemView <itemView>", translation_1.default["command.menu.option.itemView"])
21
- .addHelpText("after", `
22
- ${translation_1.default["help.option.title"]}
23
- -navigation: ${(0, stringHelper_1.optionsListString)(navigationConst_1.NAVIGATION_TYPES)}
24
- -direction: ${(0, stringHelper_1.optionsListString)(navigationConst_1.DIRECTION_TYPES)}
25
-
26
- More about rail feature, ${translation_1.default["help.option.check"]} https://doc.dana-framework.com/docs/vendorcomponents/recycling-listview
27
- `)
28
- .action(add_rail_1.default);
29
- return command;
30
- };
31
- exports.default = addRailDefinition;
@@ -1,18 +0,0 @@
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
- const commander_1 = require("commander");
7
- const translation_1 = __importDefault(require("../../translation/translation"));
8
- const add_screen_1 = __importDefault(require("../add-screen"));
9
- const addScreenDefinition = () => {
10
- const command = new commander_1.Command("add-screen");
11
- command
12
- .description(translation_1.default["command.screen.description"])
13
- .argument("[name]", translation_1.default["command.component.name"])
14
- .option("-s, --screenType [screenType]", translation_1.default["command.screen.option.type"])
15
- .action(add_screen_1.default);
16
- return command;
17
- };
18
- exports.default = addScreenDefinition;
@@ -1,18 +0,0 @@
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
- const commander_1 = require("commander");
7
- const add_scrollView_1 = __importDefault(require("../add-scrollView"));
8
- const translation_1 = __importDefault(require("../../translation/translation"));
9
- const addScrollViewDefinition = () => {
10
- return new commander_1.Command("add-scroll")
11
- .description(translation_1.default["command.scrollView.description"])
12
- .argument("[name]", translation_1.default["command.component.name"])
13
- .option("-cm, --custom", translation_1.default["command.component.customization"])
14
- .option("-i, --itemView <itemView>", translation_1.default["command.menu.option.itemView"])
15
- .option("-m, --itemMargin <itemMargin>", translation_1.default["command.menu.option.itemMargin"])
16
- .action(add_scrollView_1.default);
17
- };
18
- exports.default = addScrollViewDefinition;
@@ -1,23 +0,0 @@
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
- const commander_1 = require("commander");
7
- const translation_1 = __importDefault(require("../../translation/translation"));
8
- const login_1 = __importDefault(require("../auth/login"));
9
- const status_1 = require("../auth/status");
10
- const addAuthDefinition = () => {
11
- const command = new commander_1.Command("auth").description(translation_1.default["command.auth.description"]);
12
- const loginCmd = new commander_1.Command("login")
13
- .description(translation_1.default["command.auth.login.description"])
14
- .option("-o, --org <organization>", translation_1.default["command.auth.login.option.org"], "preprod")
15
- .action(login_1.default);
16
- command.addCommand(loginCmd);
17
- const statusCmd = new commander_1.Command("status")
18
- .description(translation_1.default["command.auth.status.description"])
19
- .action(status_1.statusAction);
20
- command.addCommand(statusCmd);
21
- return command;
22
- };
23
- exports.default = addAuthDefinition;
@@ -1,17 +0,0 @@
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
- const commander_1 = require("commander");
7
- const completion_1 = __importDefault(require("../completion"));
8
- const translation_1 = __importDefault(require("../../translation/translation"));
9
- const completionDefinition = () => {
10
- const command = new commander_1.Command("completion");
11
- command
12
- .description(translation_1.default["command.completion.description"])
13
- .argument("<shell>", translation_1.default["command.completion.argument"])
14
- .action(completion_1.default);
15
- return command;
16
- };
17
- exports.default = completionDefinition;
@@ -1,22 +0,0 @@
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
- const commander_1 = require("commander");
7
- const createApp_1 = __importDefault(require("../createApp"));
8
- const translation_1 = __importDefault(require("../../translation/translation"));
9
- const authHook_1 = require("../hooks/authHook");
10
- const createAppDefinition = () => {
11
- const command = new commander_1.Command("create-app");
12
- command
13
- .description(translation_1.default["command.create_app.description"])
14
- .argument("[projectName]", translation_1.default["command.create_app.name"])
15
- .argument("[projectDirectory]", translation_1.default["command.create_app.directory"])
16
- .option("-t, --tutorial", translation_1.default["command.create_app.tutorial"])
17
- .option("-d, --devices", translation_1.default["command.create_app.devices"])
18
- .hook("preAction", authHook_1.authHook)
19
- .action(createApp_1.default);
20
- return command;
21
- };
22
- exports.default = createAppDefinition;
@@ -1,84 +0,0 @@
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 fs_1 = require("fs");
51
- const path_1 = require("path");
52
- const node_os_1 = require("node:os");
53
- const translation_1 = __importDefault(require("../translation/translation"));
54
- const exitCodeConst_1 = require("../const/exitCodeConst");
55
- const prompts = __importStar(require("@clack/prompts"));
56
- const picocolors_1 = __importDefault(require("picocolors"));
57
- const BASH = "bash";
58
- const ZSH = "zsh";
59
- const completion = (shell) => {
60
- if (![BASH, ZSH].includes(shell)) {
61
- handleError(`Error: Shell must be either ${BASH} or ${ZSH}`);
62
- }
63
- const completionPath = (0, path_1.join)(__dirname, "../dana_completion.sh");
64
- const configFile = `.${shell}rc`;
65
- const configPath = (0, path_1.join)((0, node_os_1.homedir)(), configFile);
66
- const headerString = `\n#${"=".repeat(25)}\n# Dana CLI completion`;
67
- const sourceString = `\nsource "${completionPath}"\n`;
68
- const sourceCommand = shell === ZSH
69
- ? `${headerString}\nautoload -U compinit\ncompinit ${sourceString}`
70
- : `${headerString}${sourceString}`;
71
- try {
72
- (0, fs_1.appendFileSync)(configPath, sourceCommand);
73
- prompts.log.success(picocolors_1.default.green("✓") + translation_1.default["command.completion.success"] + ` ${configFile}`);
74
- prompts.log.info(`Run 'source ~/${configFile}' or restart your terminal`);
75
- }
76
- catch (error) {
77
- handleError(`Failed to install completion: ${error}`);
78
- }
79
- };
80
- const handleError = (message) => {
81
- prompts.log.error(message);
82
- process.exit(exitCodeConst_1.COMMAND_ERROR);
83
- };
84
- exports.default = completion;
@@ -1,130 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const prompts = __importStar(require("@clack/prompts"));
40
- const picocolors_1 = __importDefault(require("picocolors"));
41
- const SetupChecker_1 = __importDefault(require("../helpers/createApp/SetupChecker"));
42
- const UserInputGetter_1 = __importDefault(require("../helpers/createApp/UserInputGetter"));
43
- const ScriptHelper_1 = __importDefault(require("../helpers/createApp/ScriptHelper"));
44
- const CreateFileHelper_1 = __importDefault(require("../helpers/createApp/CreateFileHelper"));
45
- const UpdateFileHelper_1 = __importDefault(require("../helpers/createApp/UpdateFileHelper"));
46
- const InstallHelper_1 = __importDefault(require("../helpers/createApp/InstallHelper"));
47
- const fs_1 = __importDefault(require("fs"));
48
- const ComponentConfig_1 = __importDefault(require("../configs/ComponentConfig"));
49
- const translation_1 = __importDefault(require("../translation/translation"));
50
- const exitCodeConst_1 = require("../const/exitCodeConst");
51
- const CredentialsHelper_1 = require("../helpers/CredentialsHelper");
52
- const createApp = async (projectName, programDirectory, options) => {
53
- const { devices, tutorial } = options;
54
- prompts.intro(picocolors_1.default.inverse(`Let's create a${tutorial ? " tutorial " : " "}Dana application !`));
55
- await SetupChecker_1.default.checkSetup();
56
- const data = (await prompts.group(UserInputGetter_1.default.getPrompts(projectName, devices), {
57
- onCancel: () => ComponentConfig_1.default.handlePromptCancel(),
58
- }));
59
- data.config = await UserInputGetter_1.default.getDevicesConfig(data);
60
- data.awsProfile = CredentialsHelper_1.CredentialsHelper.get().org;
61
- const s = prompts.spinner();
62
- try {
63
- s.start(translation_1.default["task.installation.start"]);
64
- await ScriptHelper_1.default.installation([
65
- {
66
- title: "Copy template",
67
- task: async () => CreateFileHelper_1.default.copyTemplate(data),
68
- },
69
- {
70
- title: "Update templated files",
71
- task: async () => UpdateFileHelper_1.default.applyTemplatesToFiles(data),
72
- },
73
- {
74
- title: "Update npmrc",
75
- task: async () => UpdateFileHelper_1.default.updateNpmrcFile(data),
76
- },
77
- {
78
- title: "Copy for tutorial",
79
- task: async () => CreateFileHelper_1.default.copyForTutorial(data),
80
- condition: tutorial,
81
- },
82
- {
83
- title: "Update package.json",
84
- task: async () => UpdateFileHelper_1.default.updatePackageJson(data),
85
- },
86
- {
87
- title: "Copy app.config files",
88
- task: async () => CreateFileHelper_1.default.copyAppConfigFiles(data),
89
- },
90
- {
91
- title: "Update app.config.json",
92
- task: async () => UpdateFileHelper_1.default.updateAppConfigFile(data),
93
- },
94
- {
95
- title: "Install dependencies with npm",
96
- task: async () => InstallHelper_1.default.installDependencies(data),
97
- },
98
- {
99
- title: "Install grunt globally",
100
- task: async () => InstallHelper_1.default.installGrunt(),
101
- },
102
- {
103
- title: "Execute grunt tasks",
104
- task: async () => CreateFileHelper_1.default.executeGruntTasks(data),
105
- },
106
- {
107
- title: "Execute devices config",
108
- task: async () => UpdateFileHelper_1.default.setDevicesConfig(data),
109
- },
110
- {
111
- title: "Initialize git",
112
- task: async () => InstallHelper_1.default.initGit(data),
113
- },
114
- ]);
115
- s.stop(translation_1.default["task.installation.end"]);
116
- }
117
- catch (error) {
118
- const message = error instanceof Error ? error.message : "Error";
119
- s.stop(message);
120
- fs_1.default.rmSync(`./${data.directory}`, { recursive: true, force: true });
121
- prompts.outro(picocolors_1.default.red(`${translation_1.default["error.common.start.message"]}: `) +
122
- picocolors_1.default.yellow(`\n${data.directory} folder has been removed.`));
123
- process.exit(exitCodeConst_1.APP_CREATION_ERROR);
124
- }
125
- prompts.outro(translation_1.default["creation.final"]);
126
- prompts.intro(picocolors_1.default.inverse(translation_1.default["script.run.title"]));
127
- ScriptHelper_1.default.printNpmCommandForUser(data);
128
- prompts.outro("---");
129
- };
130
- exports.default = createApp;