@wiztivi/dana-cli 0.0.4 → 0.0.7

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 (75) hide show
  1. package/bin/dana.js +1 -1
  2. package/dana_completion.sh +9 -9
  3. package/dist/README.md +46 -0
  4. package/dist/commands/addComponent/addMenu/add-menu.js +20 -25
  5. package/dist/commands/addComponent/addMenu/addMenuDefinition.js +12 -17
  6. package/dist/commands/addComponent/addRail/add-rail.js +17 -22
  7. package/dist/commands/addComponent/addRail/addRailDefinition.js +19 -24
  8. package/dist/commands/addComponent/addScreen/add-screen.js +11 -49
  9. package/dist/commands/addComponent/addScreen/addScreenDefinition.js +9 -14
  10. package/dist/commands/addComponent/addScrollView/add-scrollView.js +17 -22
  11. package/dist/commands/addComponent/addScrollView/addScrollViewDefinition.js +11 -16
  12. package/dist/commands/addComponent/config/ComponentConfig.d.ts +2 -2
  13. package/dist/commands/addComponent/config/ComponentConfig.js +23 -61
  14. package/dist/commands/addComponent/config/componentTypes.js +1 -2
  15. package/dist/commands/addComponent/const/componentConst.js +8 -11
  16. package/dist/commands/addComponent/const/defaultConfig.d.ts +1 -1
  17. package/dist/commands/addComponent/const/defaultConfig.js +7 -10
  18. package/dist/commands/addComponent/const/navigationConst.d.ts +1 -1
  19. package/dist/commands/addComponent/const/navigationConst.js +7 -13
  20. package/dist/commands/addComponent/createComponent.d.ts +1 -1
  21. package/dist/commands/addComponent/createComponent.js +15 -54
  22. package/dist/commands/addComponent/helper/ComponentHelper.d.ts +2 -1
  23. package/dist/commands/addComponent/helper/ComponentHelper.js +22 -50
  24. package/dist/commands/addDevice/add-device.js +38 -73
  25. package/dist/commands/addDevice/addDeviceDefinition.js +9 -14
  26. package/dist/commands/addDevice/deviceConfig/androidtvConfig.d.ts +1 -1
  27. package/dist/commands/addDevice/deviceConfig/androidtvConfig.js +39 -77
  28. package/dist/commands/addDevice/deviceConfig/configTypes.js +1 -2
  29. package/dist/commands/addDevice/deviceConfig/deviceConfig.js +1 -3
  30. package/dist/commands/addDevice/deviceConfig/tizenConfig.d.ts +1 -1
  31. package/dist/commands/addDevice/deviceConfig/tizenConfig.js +10 -15
  32. package/dist/commands/addDevice/deviceConfig/tvosConfig.js +8 -13
  33. package/dist/commands/addDevice/deviceConfig/webosConfig.d.ts +1 -1
  34. package/dist/commands/addDevice/deviceConfig/webosConfig.js +25 -63
  35. package/dist/commands/addDevice/helper/addDeviceHelper.js +7 -12
  36. package/dist/commands/authentication/authDefinition.js +14 -19
  37. package/dist/commands/authentication/authHook.js +5 -9
  38. package/dist/commands/authentication/authentConst.js +4 -7
  39. package/dist/commands/authentication/commands/login.js +29 -67
  40. package/dist/commands/authentication/commands/status.js +12 -52
  41. package/dist/commands/authentication/helper/CodeArtifactHelper.d.ts +1 -1
  42. package/dist/commands/authentication/helper/CodeArtifactHelper.js +14 -20
  43. package/dist/commands/authentication/helper/CredentialsHelper.js +8 -15
  44. package/dist/commands/commandHelp/customHelp.js +6 -11
  45. package/dist/commands/completion/completion.js +15 -51
  46. package/dist/commands/completion/completionDefinition.js +8 -13
  47. package/dist/commands/createApp/const/setupConst.js +1 -5
  48. package/dist/commands/createApp/createApp.js +42 -80
  49. package/dist/commands/createApp/createAppDefinition.js +13 -18
  50. package/dist/commands/createApp/helpers/CreateAppHelper.d.ts +9 -9
  51. package/dist/commands/createApp/helpers/CreateAppHelper.js +20 -58
  52. package/dist/commands/createApp/helpers/SetupChecker.d.ts +1 -1
  53. package/dist/commands/createApp/helpers/SetupChecker.js +14 -52
  54. package/dist/common/commonConst.js +1 -4
  55. package/dist/common/const/deviceConst.js +1 -14
  56. package/dist/common/const/exitCodeConst.js +7 -10
  57. package/dist/common/helpers/CreateFileHelper.d.ts +1 -1
  58. package/dist/common/helpers/CreateFileHelper.js +22 -27
  59. package/dist/common/helpers/InputValidator.js +7 -15
  60. package/dist/common/helpers/InstallHelper.d.ts +1 -1
  61. package/dist/common/helpers/InstallHelper.js +13 -18
  62. package/dist/common/helpers/UpdateFileHelper.d.ts +7 -1
  63. package/dist/common/helpers/UpdateFileHelper.js +46 -43
  64. package/dist/common/helpers/UserInputGetter.d.ts +1 -1
  65. package/dist/common/helpers/UserInputGetter.js +20 -58
  66. package/dist/common/helpers/handlebarsHelper.js +12 -17
  67. package/dist/common/helpers/stringHelper.d.ts +1 -1
  68. package/dist/common/helpers/stringHelper.js +2 -7
  69. package/dist/common/translation/translation.js +3 -8
  70. package/dist/common/types/helperTypes.d.ts +2 -2
  71. package/dist/common/types/helperTypes.js +1 -3
  72. package/dist/dana_completion.sh +9 -9
  73. package/dist/index.js +2 -4
  74. package/dist/program.js +30 -35
  75. package/package.json +9 -4
@@ -1,41 +1,3 @@
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
1
  /*
40
2
  * Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
41
3
  * All Rights Reserved
@@ -47,16 +9,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
47
9
  * This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
48
10
  *
49
11
  */
50
- const prompts = __importStar(require("@clack/prompts"));
51
- const ComponentHelper_1 = __importDefault(require("../../addComponent/helper/ComponentHelper"));
52
- const node_fs_1 = __importDefault(require("node:fs"));
53
- const node_path_1 = __importDefault(require("node:path"));
54
- const deviceConfig_1 = __importDefault(require("./deviceConfig"));
55
- const picocolors_1 = __importDefault(require("picocolors"));
56
- const setupConst_1 = require("../../createApp/const/setupConst");
57
- const InputValidator_1 = require("../../../common/helpers/InputValidator");
58
- const deviceConst_1 = require("../../../common/const/deviceConst");
59
- const WebosConfig = class extends deviceConfig_1.default {
12
+ import * as prompts from "@clack/prompts";
13
+ import ComponentHelper from "../../addComponent/helper/ComponentHelper.js";
14
+ import fs from "node:fs";
15
+ import path from "node:path";
16
+ import DeviceConfig from "./deviceConfig.js";
17
+ import colors from "picocolors";
18
+ import { DEFAULT_IMAGE_URL } from "../../createApp/const/setupConst.js";
19
+ import { validInputLength } from "../../../common/helpers/InputValidator.js";
20
+ import { CSS } from "../../../common/const/deviceConst.js";
21
+ const WebosConfig = class extends DeviceConfig {
60
22
  static appConfig = {
61
23
  css: {
62
24
  "template-webos_css": {
@@ -85,9 +47,9 @@ const WebosConfig = class extends deviceConfig_1.default {
85
47
  const appId = (await prompts.text({
86
48
  message: "What is the appId ?",
87
49
  placeholder: "com.yourname.ui",
88
- validate: (value) => (0, InputValidator_1.validInputLength)(value, errorMessage),
50
+ validate: (value) => validInputLength(value, errorMessage),
89
51
  }));
90
- ComponentHelper_1.default.handleCancellation(appId);
52
+ ComponentHelper.handleCancellation(appId);
91
53
  return appId;
92
54
  };
93
55
  /**
@@ -99,9 +61,9 @@ const WebosConfig = class extends deviceConfig_1.default {
99
61
  message: "What is the vendor name?",
100
62
  placeholder: "Wiztivi",
101
63
  initialValue: "Wiztivi",
102
- validate: (value) => (0, InputValidator_1.validInputLength)(value, errorMessage),
64
+ validate: (value) => validInputLength(value, errorMessage),
103
65
  }));
104
- ComponentHelper_1.default.handleCancellation(vendor);
66
+ ComponentHelper.handleCancellation(vendor);
105
67
  return vendor;
106
68
  };
107
69
  /**
@@ -114,9 +76,9 @@ const WebosConfig = class extends deviceConfig_1.default {
114
76
  message: "What is app name (to be displayed on store and webOS devices)?",
115
77
  placeholder: "My app",
116
78
  initialValue: "Dana UI",
117
- validate: (value) => (0, InputValidator_1.validInputLength)(value, errorMessage),
79
+ validate: (value) => validInputLength(value, errorMessage),
118
80
  }));
119
- ComponentHelper_1.default.handleCancellation(appTitle);
81
+ ComponentHelper.handleCancellation(appTitle);
120
82
  return appTitle;
121
83
  };
122
84
  /**
@@ -124,7 +86,7 @@ const WebosConfig = class extends deviceConfig_1.default {
124
86
  * @returns {String}
125
87
  */
126
88
  static _getAppIcon = () => {
127
- return Promise.resolve(setupConst_1.DEFAULT_IMAGE_URL);
89
+ return Promise.resolve(DEFAULT_IMAGE_URL);
128
90
  };
129
91
  /**
130
92
  * Ask back handling
@@ -134,7 +96,7 @@ const WebosConfig = class extends deviceConfig_1.default {
134
96
  const backHistory = (await prompts.confirm({
135
97
  message: "Does your app handle the back button manually ?",
136
98
  }));
137
- ComponentHelper_1.default.handleCancellation(backHistory);
99
+ ComponentHelper.handleCancellation(backHistory);
138
100
  return backHistory;
139
101
  };
140
102
  /**
@@ -155,24 +117,24 @@ const WebosConfig = class extends deviceConfig_1.default {
155
117
  process.exit(0);
156
118
  },
157
119
  }));
158
- ComponentHelper_1.default.handleCancellation(data);
120
+ ComponentHelper.handleCancellation(data);
159
121
  return data;
160
122
  };
161
123
  static getConfig = async () => {
162
- prompts.log.info(picocolors_1.default.bold("Let's configure LG"));
124
+ prompts.log.info(colors.bold("Let's configure LG"));
163
125
  return {
164
- renderers: [deviceConst_1.CSS],
126
+ renderers: [CSS],
165
127
  device: await this.getAppConfigProperties(),
166
128
  };
167
129
  };
168
130
  static setConfig = ({ directory, config }) => {
169
- const filePath = node_path_1.default.join(directory, "profiles", "app.config.webos.json");
170
- let jsonData = JSON.parse(node_fs_1.default.readFileSync(filePath).toString());
131
+ const filePath = path.join(directory, "profiles", "app.config.webos.json");
132
+ let jsonData = JSON.parse(fs.readFileSync(filePath).toString());
171
133
  jsonData.webos ??= { device: {} };
172
134
  jsonData.webos.device = { ...jsonData.webos?.device, ...config.device };
173
135
  jsonData = this.updateProfileJsonWithRenderers(jsonData, config.renderers);
174
- node_fs_1.default.writeFileSync(filePath, JSON.stringify(jsonData, null, 4));
136
+ fs.writeFileSync(filePath, JSON.stringify(jsonData, null, 4));
175
137
  return Promise.resolve("Webos configuration done");
176
138
  };
177
139
  };
178
- exports.default = WebosConfig;
140
+ export default WebosConfig;
@@ -1,18 +1,13 @@
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 node_child_process_1 = require("node:child_process");
7
- const node_fs_1 = require("node:fs");
8
- const node_path_1 = __importDefault(require("node:path"));
1
+ import { execSync } from "node:child_process";
2
+ import { readFileSync } from "node:fs";
3
+ import path from "node:path";
9
4
  const AddDeviceHelper = class {
10
5
  /**
11
6
  * clean on error
12
7
  */
13
8
  static cleanOnError = () => {
14
9
  try {
15
- (0, node_child_process_1.execSync)(`git clean -d -f && git reset --hard head`);
10
+ execSync(`git clean -d -f && git reset --hard head`);
16
11
  }
17
12
  catch {
18
13
  throw new Error("Files deletion failed. Delete changes manually.");
@@ -24,8 +19,8 @@ const AddDeviceHelper = class {
24
19
  * We use script so we can get renderers for smartTv
25
20
  */
26
21
  static getInstalledDevices = (directory) => {
27
- const filepath = node_path_1.default.join(directory, "package.json");
28
- const jsonData = JSON.parse((0, node_fs_1.readFileSync)(filepath).toString());
22
+ const filepath = path.join(directory, "package.json");
23
+ const jsonData = JSON.parse(readFileSync(filepath).toString());
29
24
  const installedDevices = [];
30
25
  for (const t of Object.keys(jsonData.scripts)) {
31
26
  if (t.includes("start:")) {
@@ -36,4 +31,4 @@ const AddDeviceHelper = class {
36
31
  return installedDevices;
37
32
  };
38
33
  };
39
- exports.default = AddDeviceHelper;
34
+ export default AddDeviceHelper;
@@ -1,24 +1,19 @@
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("../../common/translation/translation"));
8
- const login_1 = __importDefault(require("./commands/login"));
9
- const status_1 = require("./commands/status");
10
- const authentConst_1 = require("./authentConst");
1
+ import { Command } from "commander";
2
+ import translation from "../../common/translation/translation.js";
3
+ import login from "./commands/login.js";
4
+ import { statusAction } from "./commands/status.js";
5
+ import { DEFAULT_ORG } from "./authentConst.js";
11
6
  const addAuthDefinition = () => {
12
- const command = new commander_1.Command("auth").description(translation_1.default["command.auth.description"]);
13
- const loginCmd = new commander_1.Command("login")
14
- .description(translation_1.default["command.auth.login.description"])
15
- .option("-o, --org <organization>", translation_1.default["command.auth.login.option.org"], authentConst_1.DEFAULT_ORG)
16
- .action(login_1.default);
7
+ const command = new Command("auth").description(translation["command.auth.description"]);
8
+ const loginCmd = new Command("login")
9
+ .description(translation["command.auth.login.description"])
10
+ .option("-o, --org <organization>", translation["command.auth.login.option.org"], DEFAULT_ORG)
11
+ .action(login);
17
12
  command.addCommand(loginCmd);
18
- const statusCmd = new commander_1.Command("status")
19
- .description(translation_1.default["command.auth.status.description"])
20
- .action(status_1.statusAction);
13
+ const statusCmd = new Command("status")
14
+ .description(translation["command.auth.status.description"])
15
+ .action(statusAction);
21
16
  command.addCommand(statusCmd);
22
17
  return command;
23
18
  };
24
- exports.default = addAuthDefinition;
19
+ export default addAuthDefinition;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
4
3
  * All Rights Reserved
@@ -10,14 +9,11 @@
10
9
  * This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
11
10
  *
12
11
  */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.authHook = void 0;
15
- const status_1 = require("./commands/status");
16
- const exitCodeConst_1 = require("../../common/const/exitCodeConst");
17
- const authHook = () => {
18
- const isLogged = (0, status_1.status)() === status_1.LOGIN_STATUS.LOGGED;
12
+ import { status, LOGIN_STATUS } from "./commands/status.js";
13
+ import { LOGIN_ERROR } from "../../common/const/exitCodeConst.js";
14
+ export const authHook = () => {
15
+ const isLogged = status() === LOGIN_STATUS.LOGGED;
19
16
  if (!isLogged) {
20
- process.exit(exitCodeConst_1.LOGIN_ERROR);
17
+ process.exit(LOGIN_ERROR);
21
18
  }
22
19
  };
23
- exports.authHook = authHook;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_ORG = exports.REGION = exports.DOMAIN_OWNER = exports.DOMAIN = void 0;
4
- exports.DOMAIN = "dana";
5
- exports.DOMAIN_OWNER = "733912940672";
6
- exports.REGION = "eu-central-1";
7
- exports.DEFAULT_ORG = "public";
1
+ export const DOMAIN = "dana";
2
+ export const DOMAIN_OWNER = "733912940672";
3
+ export const REGION = "eu-central-1";
4
+ export const DEFAULT_ORG = "public";
@@ -1,59 +1,21 @@
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 node_child_process_1 = require("node: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("../../../common/const/exitCodeConst");
47
- const CredentialsHelper_1 = require("../helper/CredentialsHelper");
48
- const authentConst_1 = require("../authentConst");
49
- const CodeArtifactHelper_1 = require("../helper/CodeArtifactHelper");
1
+ import { GetAuthorizationTokenCommand } from "@aws-sdk/client-codeartifact";
2
+ import * as prompts from "@clack/prompts";
3
+ import { execSync } from "node:child_process";
4
+ import express from "express";
5
+ import getPort from "get-port";
6
+ import open from "open";
7
+ import colors from "picocolors";
8
+ import { LOGIN_ERROR } from "../../../common/const/exitCodeConst.js";
9
+ import { CredentialsHelper } from "../helper/CredentialsHelper.js";
10
+ import { DEFAULT_ORG, DOMAIN, DOMAIN_OWNER } from "../authentConst.js";
11
+ import { getRepositoryEndpoint, createCodeArtifactClient } from "../helper/CodeArtifactHelper.js";
50
12
  /*
51
13
  Login to DANA backend (with aws and cognito) and connect to npm codeartifact
52
14
  More info: https://github.com/wiztivi-rd/dana-cli/wiki/Login
53
15
  */
54
- const login = async ({ org = authentConst_1.DEFAULT_ORG }) => {
16
+ const login = async ({ org = DEFAULT_ORG }) => {
55
17
  const apiUrl = `https://api.${org}.dana-framework.com`; // Or http://localhost:3001
56
- const credentials = CredentialsHelper_1.CredentialsHelper.get();
18
+ const credentials = CredentialsHelper.get();
57
19
  if (credentials) {
58
20
  try {
59
21
  if (new Date(credentials.aws.expiration) < new Date()) {
@@ -67,7 +29,7 @@ const login = async ({ org = authentConst_1.DEFAULT_ORG }) => {
67
29
  ...refreshedCreds.token,
68
30
  refresh_token: credentials.dana.refresh_token,
69
31
  };
70
- CredentialsHelper_1.CredentialsHelper.store(credentials);
32
+ CredentialsHelper.store(credentials);
71
33
  }
72
34
  prompts.log.info(`Retrieved credentials for ${org} from local cache`);
73
35
  await codeartifactLogin(org, credentials.aws);
@@ -80,8 +42,8 @@ const login = async ({ org = authentConst_1.DEFAULT_ORG }) => {
80
42
  }
81
43
  prompts.intro(`Login to ${org}...`);
82
44
  try {
83
- const port = await (0, get_port_1.default)();
84
- const app = (0, express_1.default)();
45
+ const port = await getPort();
46
+ const app = express();
85
47
  app.disable("x-powered-by");
86
48
  const server = app.listen(port);
87
49
  app.get("/callback", async (req, res) => {
@@ -91,10 +53,10 @@ const login = async ({ org = authentConst_1.DEFAULT_ORG }) => {
91
53
  }
92
54
  const token = JSON.parse(req.query.token);
93
55
  const awsCredentials = JSON.parse(req.query.aws);
94
- CredentialsHelper_1.CredentialsHelper.store({ aws: awsCredentials, dana: token, org });
56
+ CredentialsHelper.store({ aws: awsCredentials, dana: token, org });
95
57
  // Login to codeartifact repository
96
58
  await codeartifactLogin(org, awsCredentials);
97
- prompts.outro(picocolors_1.default.green("✓") + ` Login successfull`);
59
+ prompts.outro(colors.green("✓") + ` Login successfull`);
98
60
  res.send("Login successful! You can close this window.");
99
61
  }
100
62
  catch (err) {
@@ -106,7 +68,7 @@ const login = async ({ org = authentConst_1.DEFAULT_ORG }) => {
106
68
  server.close();
107
69
  }
108
70
  });
109
- await (0, open_1.default)(`${apiUrl}/login?port=${port}`);
71
+ await open(`${apiUrl}/login?port=${port}`);
110
72
  }
111
73
  catch (error) {
112
74
  console.error(error);
@@ -115,27 +77,27 @@ const login = async ({ org = authentConst_1.DEFAULT_ORG }) => {
115
77
  };
116
78
  const handleError = (error) => {
117
79
  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);
80
+ prompts.outro(colors.red(`An issue occurred :` + message));
81
+ process.exit(LOGIN_ERROR);
120
82
  };
121
83
  const codeartifactLogin = async (organization, credentials) => {
122
84
  // Create CodeArtifact client with credentials
123
- const client = (0, CodeArtifactHelper_1.createCodeArtifactClient)(credentials);
85
+ const client = createCodeArtifactClient(credentials);
124
86
  // Get authorization token
125
- const tokenCommand = new client_codeartifact_1.GetAuthorizationTokenCommand({
126
- domain: authentConst_1.DOMAIN,
127
- domainOwner: authentConst_1.DOMAIN_OWNER,
87
+ const tokenCommand = new GetAuthorizationTokenCommand({
88
+ domain: DOMAIN,
89
+ domainOwner: DOMAIN_OWNER,
128
90
  });
129
91
  const { authorizationToken, expiration } = await client.send(tokenCommand);
130
92
  if (!authorizationToken) {
131
93
  throw new Error("Authorization token not found");
132
94
  }
133
95
  // Get repository endpoint
134
- const repositoryEndpoint = await (0, CodeArtifactHelper_1.getRepositoryEndpoint)({ organization, credentials, client, format: "npm" });
96
+ const repositoryEndpoint = await getRepositoryEndpoint({ organization, credentials, client, format: "npm" });
135
97
  // Configure npm with the repository and token
136
- (0, node_child_process_1.execSync)(`npm config set @dana:registry=${repositoryEndpoint}`);
137
- (0, node_child_process_1.execSync)(`npm config set //${repositoryEndpoint.replace(/^https?:\/\//, "")}:_authToken=${authorizationToken}`);
98
+ execSync(`npm config set @dana:registry=${repositoryEndpoint}`);
99
+ execSync(`npm config set //${repositoryEndpoint.replace(/^https?:\/\//, "")}:_authToken=${authorizationToken}`);
138
100
  const expiresAt = expiration ? new Date(expiration).toLocaleString() : "unknown";
139
101
  prompts.log.step(`Successfully configured npm to use AWS CodeArtifact repository ${repositoryEndpoint}. \nLogin expires in 12 hours at: ${expiresAt}`);
140
102
  };
141
- exports.default = login;
103
+ export default login;
@@ -1,76 +1,36 @@
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("../helper/CredentialsHelper");
44
- const translation_1 = __importDefault(require("../../../common/translation/translation"));
1
+ import * as prompts from "@clack/prompts";
2
+ import jwt from "jsonwebtoken";
3
+ import colors from "picocolors";
4
+ import { CredentialsHelper } from "../helper/CredentialsHelper.js";
5
+ import translation from "../../../common/translation/translation.js";
45
6
  var LOGIN_STATUS;
46
7
  (function (LOGIN_STATUS) {
47
8
  LOGIN_STATUS[LOGIN_STATUS["LOGGED"] = 1] = "LOGGED";
48
9
  LOGIN_STATUS[LOGIN_STATUS["NOT_LOGGED"] = 2] = "NOT_LOGGED";
49
10
  LOGIN_STATUS[LOGIN_STATUS["TOKEN_EXPIRED"] = 3] = "TOKEN_EXPIRED";
50
- })(LOGIN_STATUS || (exports.LOGIN_STATUS = LOGIN_STATUS = {}));
11
+ })(LOGIN_STATUS || (LOGIN_STATUS = {}));
51
12
  const status = () => {
52
- const credentials = CredentialsHelper_1.CredentialsHelper.get();
13
+ const credentials = CredentialsHelper.get();
53
14
  if (!credentials?.dana?.id_token) {
54
- prompts.log.error(`${translation_1.default["login.error.not_logged"]} ${translation_1.default["login.info.please_login"]}`);
15
+ prompts.log.error(`${translation["login.error.not_logged"]} ${translation["login.info.please_login"]}`);
55
16
  return LOGIN_STATUS.NOT_LOGGED;
56
17
  }
57
18
  const id_token = credentials.dana.id_token;
58
- const { given_name, family_name, email, exp } = jsonwebtoken_1.default.decode(id_token);
19
+ const { given_name, family_name, email, exp } = jwt.decode(id_token);
59
20
  const expiration = exp && new Date(exp * 1000);
60
21
  if (expiration && new Date() > expiration) {
61
- prompts.log.error(`${translation_1.default["login.info.token_expired"]} ${translation_1.default["login.info.please_login"]}`);
22
+ prompts.log.error(`${translation["login.info.token_expired"]} ${translation["login.info.please_login"]}`);
62
23
  return LOGIN_STATUS.TOKEN_EXPIRED;
63
24
  }
64
25
  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}
26
+ prompts.log.success(`${translation["login.info.logged"]} ${colors.bold(credentials.org)}: ${colors.bold(given_name + " " + family_name)} (${email})${expStr}
66
27
  `);
67
28
  return LOGIN_STATUS.LOGGED;
68
29
  };
69
- exports.status = status;
70
30
  /**
71
31
  * Sends void intentionally to be used a Commander acceptable command
72
32
  */
73
33
  const statusAction = () => {
74
34
  status();
75
35
  };
76
- exports.statusAction = statusAction;
36
+ export { LOGIN_STATUS, status, statusAction };
@@ -1,5 +1,5 @@
1
1
  import { CodeartifactClient } from "@aws-sdk/client-codeartifact";
2
- import { AwsCredentials } from "./CredentialsHelper";
2
+ import { AwsCredentials } from "./CredentialsHelper.js";
3
3
  interface GetRepositoryEndpointOptions {
4
4
  organization: string;
5
5
  credentials?: AwsCredentials;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
4
3
  * All Rights Reserved
@@ -10,21 +9,19 @@
10
9
  * This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
11
10
  *
12
11
  */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.formatRepositoryString = exports.createCodeArtifactClient = exports.getRepositoryEndpoint = void 0;
15
- const client_codeartifact_1 = require("@aws-sdk/client-codeartifact");
16
- const CredentialsHelper_1 = require("./CredentialsHelper");
17
- const authentConst_1 = require("../authentConst");
18
- const getRepositoryEndpoint = async ({ organization, credentials, client, format = "npm", }) => {
19
- const actualCredentials = credentials ?? CredentialsHelper_1.CredentialsHelper.get()?.aws;
12
+ import { CodeartifactClient, GetRepositoryEndpointCommand } from "@aws-sdk/client-codeartifact";
13
+ import { CredentialsHelper } from "./CredentialsHelper.js";
14
+ import { DOMAIN, DOMAIN_OWNER, REGION } from "../authentConst.js";
15
+ export const getRepositoryEndpoint = async ({ organization, credentials, client, format = "npm", }) => {
16
+ const actualCredentials = credentials ?? CredentialsHelper.get()?.aws;
20
17
  if (!actualCredentials) {
21
18
  throw new Error("No valid credentials available.");
22
19
  }
23
- const actualClient = client ?? (0, exports.createCodeArtifactClient)(actualCredentials);
24
- const repository = (0, exports.formatRepositoryString)(organization);
25
- const endpointCommand = new client_codeartifact_1.GetRepositoryEndpointCommand({
26
- domain: authentConst_1.DOMAIN,
27
- domainOwner: authentConst_1.DOMAIN_OWNER,
20
+ const actualClient = client ?? createCodeArtifactClient(actualCredentials);
21
+ const repository = formatRepositoryString(organization);
22
+ const endpointCommand = new GetRepositoryEndpointCommand({
23
+ domain: DOMAIN,
24
+ domainOwner: DOMAIN_OWNER,
28
25
  repository,
29
26
  format,
30
27
  });
@@ -34,10 +31,9 @@ const getRepositoryEndpoint = async ({ organization, credentials, client, format
34
31
  }
35
32
  return repositoryEndpoint;
36
33
  };
37
- exports.getRepositoryEndpoint = getRepositoryEndpoint;
38
- const createCodeArtifactClient = (credentials) => {
39
- return new client_codeartifact_1.CodeartifactClient({
40
- region: authentConst_1.REGION,
34
+ export const createCodeArtifactClient = (credentials) => {
35
+ return new CodeartifactClient({
36
+ region: REGION,
41
37
  credentials: {
42
38
  accessKeyId: credentials.accessKeyId,
43
39
  secretAccessKey: credentials.secretAccessKey,
@@ -45,8 +41,6 @@ const createCodeArtifactClient = (credentials) => {
45
41
  },
46
42
  });
47
43
  };
48
- exports.createCodeArtifactClient = createCodeArtifactClient;
49
- const formatRepositoryString = (org) => {
44
+ export const formatRepositoryString = (org) => {
50
45
  return `dana-${org}-repository`;
51
46
  };
52
- exports.formatRepositoryString = formatRepositoryString;
@@ -1,22 +1,15 @@
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.CredentialsHelper = void 0;
7
- const node_fs_1 = require("node:fs");
8
- const node_os_1 = require("node:os");
9
- const node_path_1 = __importDefault(require("node:path"));
10
- class CredentialsHelper {
11
- static filePath = node_path_1.default.join((0, node_os_1.homedir)(), ".dana.json");
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import path from "node:path";
4
+ export class CredentialsHelper {
5
+ static filePath = path.join(homedir(), ".dana.json");
12
6
  static store(credentials) {
13
- (0, node_fs_1.writeFileSync)(this.filePath, JSON.stringify(credentials, null, 4));
7
+ writeFileSync(this.filePath, JSON.stringify(credentials, null, 4));
14
8
  }
15
9
  static get() {
16
- if (!(0, node_fs_1.existsSync)(this.filePath)) {
10
+ if (!existsSync(this.filePath)) {
17
11
  return null;
18
12
  }
19
- return JSON.parse((0, node_fs_1.readFileSync)(this.filePath).toString());
13
+ return JSON.parse(readFileSync(this.filePath).toString());
20
14
  }
21
15
  }
22
- exports.CredentialsHelper = CredentialsHelper;