@wiztivi/dana-cli 0.0.4 → 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.
- package/bin/dana.js +1 -1
- package/dist/commands/addComponent/addMenu/add-menu.js +20 -25
- package/dist/commands/addComponent/addMenu/addMenuDefinition.js +12 -17
- package/dist/commands/addComponent/addRail/add-rail.js +17 -22
- package/dist/commands/addComponent/addRail/addRailDefinition.js +19 -24
- package/dist/commands/addComponent/addScreen/add-screen.js +11 -49
- package/dist/commands/addComponent/addScreen/addScreenDefinition.js +9 -14
- package/dist/commands/addComponent/addScrollView/add-scrollView.js +17 -22
- package/dist/commands/addComponent/addScrollView/addScrollViewDefinition.js +11 -16
- package/dist/commands/addComponent/config/ComponentConfig.d.ts +2 -2
- package/dist/commands/addComponent/config/ComponentConfig.js +23 -61
- package/dist/commands/addComponent/config/componentTypes.js +1 -2
- package/dist/commands/addComponent/const/componentConst.js +8 -11
- package/dist/commands/addComponent/const/defaultConfig.d.ts +1 -1
- package/dist/commands/addComponent/const/defaultConfig.js +7 -10
- package/dist/commands/addComponent/const/navigationConst.d.ts +1 -1
- package/dist/commands/addComponent/const/navigationConst.js +7 -13
- package/dist/commands/addComponent/createComponent.d.ts +1 -1
- package/dist/commands/addComponent/createComponent.js +15 -54
- package/dist/commands/addComponent/helper/ComponentHelper.d.ts +2 -1
- package/dist/commands/addComponent/helper/ComponentHelper.js +22 -50
- package/dist/commands/addDevice/add-device.js +34 -72
- package/dist/commands/addDevice/addDeviceDefinition.js +9 -14
- package/dist/commands/addDevice/deviceConfig/androidtvConfig.d.ts +1 -1
- package/dist/commands/addDevice/deviceConfig/androidtvConfig.js +39 -77
- package/dist/commands/addDevice/deviceConfig/configTypes.js +1 -2
- package/dist/commands/addDevice/deviceConfig/deviceConfig.js +1 -3
- package/dist/commands/addDevice/deviceConfig/tizenConfig.d.ts +1 -1
- package/dist/commands/addDevice/deviceConfig/tizenConfig.js +10 -15
- package/dist/commands/addDevice/deviceConfig/tvosConfig.js +8 -13
- package/dist/commands/addDevice/deviceConfig/webosConfig.d.ts +1 -1
- package/dist/commands/addDevice/deviceConfig/webosConfig.js +25 -63
- package/dist/commands/addDevice/helper/addDeviceHelper.js +7 -12
- package/dist/commands/authentication/authDefinition.js +14 -19
- package/dist/commands/authentication/authHook.js +5 -9
- package/dist/commands/authentication/authentConst.js +4 -7
- package/dist/commands/authentication/commands/login.js +29 -67
- package/dist/commands/authentication/commands/status.js +12 -52
- package/dist/commands/authentication/helper/CodeArtifactHelper.d.ts +1 -1
- package/dist/commands/authentication/helper/CodeArtifactHelper.js +14 -20
- package/dist/commands/authentication/helper/CredentialsHelper.js +8 -15
- package/dist/commands/commandHelp/customHelp.js +6 -11
- package/dist/commands/completion/completion.js +15 -51
- package/dist/commands/completion/completionDefinition.js +8 -13
- package/dist/commands/createApp/const/setupConst.js +1 -5
- package/dist/commands/createApp/createApp.js +42 -80
- package/dist/commands/createApp/createAppDefinition.js +13 -18
- package/dist/commands/createApp/helpers/CreateAppHelper.d.ts +9 -9
- package/dist/commands/createApp/helpers/CreateAppHelper.js +20 -58
- package/dist/commands/createApp/helpers/SetupChecker.d.ts +1 -1
- package/dist/commands/createApp/helpers/SetupChecker.js +14 -52
- package/dist/common/commonConst.js +1 -4
- package/dist/common/const/deviceConst.js +1 -14
- package/dist/common/const/exitCodeConst.js +7 -10
- package/dist/common/helpers/CreateFileHelper.d.ts +1 -1
- package/dist/common/helpers/CreateFileHelper.js +22 -27
- package/dist/common/helpers/InputValidator.js +7 -15
- package/dist/common/helpers/InstallHelper.d.ts +1 -1
- package/dist/common/helpers/InstallHelper.js +13 -18
- package/dist/common/helpers/UpdateFileHelper.d.ts +1 -1
- package/dist/common/helpers/UpdateFileHelper.js +34 -39
- package/dist/common/helpers/UserInputGetter.d.ts +1 -1
- package/dist/common/helpers/UserInputGetter.js +20 -58
- package/dist/common/helpers/handlebarsHelper.js +12 -17
- package/dist/common/helpers/stringHelper.d.ts +1 -1
- package/dist/common/helpers/stringHelper.js +2 -7
- package/dist/common/translation/translation.js +3 -8
- package/dist/common/types/helperTypes.d.ts +2 -2
- package/dist/common/types/helperTypes.js +1 -3
- package/dist/index.js +2 -4
- package/dist/program.js +30 -35
- package/package.json +6 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MenuConfig, RailConfig, ScrollViewConfig } from "../config/componentTypes";
|
|
1
|
+
import { MenuConfig, RailConfig, ScrollViewConfig } from "../config/componentTypes.js";
|
|
2
2
|
export declare const RAIL_DEFAULT_CONFIG: RailConfig;
|
|
3
3
|
export declare const MENU_DEFAULT_CONFIG: MenuConfig;
|
|
4
4
|
export declare const SCROLLVIEW_DEFAULT_CONFIG: ScrollViewConfig;
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SCROLLVIEW_DEFAULT_CONFIG = exports.MENU_DEFAULT_CONFIG = exports.RAIL_DEFAULT_CONFIG = void 0;
|
|
4
|
-
const componentConst_1 = require("./componentConst");
|
|
5
|
-
exports.RAIL_DEFAULT_CONFIG = {
|
|
1
|
+
import { MENU, SCROLL_VIEW, RAIL } from "./componentConst.js";
|
|
2
|
+
export const RAIL_DEFAULT_CONFIG = {
|
|
6
3
|
navigation: "FixedNavigationType",
|
|
7
4
|
isCyclic: false,
|
|
8
5
|
direction: "horizontal",
|
|
9
6
|
name: "mockRail",
|
|
10
7
|
itemView: "mockTile",
|
|
11
|
-
type:
|
|
8
|
+
type: RAIL,
|
|
12
9
|
addMock: true,
|
|
13
10
|
};
|
|
14
|
-
|
|
11
|
+
export const MENU_DEFAULT_CONFIG = {
|
|
15
12
|
name: "mockMenu",
|
|
16
13
|
itemMargin: 20,
|
|
17
14
|
itemView: "ButtonItem",
|
|
18
15
|
direction: "horizontal",
|
|
19
16
|
addMock: true,
|
|
20
|
-
type:
|
|
17
|
+
type: MENU,
|
|
21
18
|
};
|
|
22
|
-
|
|
19
|
+
export const SCROLLVIEW_DEFAULT_CONFIG = {
|
|
23
20
|
name: "mock",
|
|
24
21
|
itemMargin: 550,
|
|
25
22
|
itemView: "Rail",
|
|
26
|
-
type:
|
|
23
|
+
type: SCROLL_VIEW,
|
|
27
24
|
};
|
|
@@ -1,36 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DIRECTION_TYPES = exports.NAVIGATION_TYPES = void 0;
|
|
7
|
-
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
-
exports.NAVIGATION_TYPES = [
|
|
1
|
+
import colors from "picocolors";
|
|
2
|
+
export const NAVIGATION_TYPES = [
|
|
9
3
|
{
|
|
10
4
|
value: "MFixedNavigationType",
|
|
11
|
-
label:
|
|
5
|
+
label: colors.bold("Fixed. ") + "Focus is fixed on the left side of the list.",
|
|
12
6
|
command: "fixed",
|
|
13
7
|
},
|
|
14
8
|
{
|
|
15
9
|
value: "MLMRNavigationType",
|
|
16
|
-
label:
|
|
10
|
+
label: colors.bold("Left-Middle-Right. ") +
|
|
17
11
|
"Focus starts on the left side, then moves and stays to the middle, then goes to the right side when the list ends",
|
|
18
12
|
command: "lmr",
|
|
19
13
|
},
|
|
20
14
|
{
|
|
21
15
|
value: "MLRNavigationType",
|
|
22
|
-
label:
|
|
16
|
+
label: colors.bold("Left-Right. ") +
|
|
23
17
|
" Focus moves in the chosen direction to the edge of the list. Then the list scrolls to show the next items.",
|
|
24
18
|
command: "lr",
|
|
25
19
|
},
|
|
26
20
|
{
|
|
27
21
|
value: "MPaginateNavigationType",
|
|
28
|
-
label:
|
|
22
|
+
label: colors.bold("Paginated. ") +
|
|
29
23
|
" Focus moves to the end of the visible items. Then, all items are replaced by new ones.",
|
|
30
24
|
command: "paginated",
|
|
31
25
|
},
|
|
32
26
|
];
|
|
33
|
-
|
|
27
|
+
export const DIRECTION_TYPES = [
|
|
34
28
|
{ value: `HORIZONTAL`, label: "HORIZONTAL", command: "h" },
|
|
35
29
|
{ value: `VERTICAL`, label: "VERTICAL", command: "v" },
|
|
36
30
|
];
|
|
@@ -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,71 +9,33 @@
|
|
|
10
9
|
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
11
10
|
*
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 ComponentHelper_1 = __importDefault(require("./helper/ComponentHelper"));
|
|
51
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
52
|
-
const node_fs_1 = require("node:fs");
|
|
53
|
-
const handlebarsHelper_1 = require("../../common/helpers/handlebarsHelper");
|
|
54
|
-
const prompts = __importStar(require("@clack/prompts"));
|
|
55
|
-
const exitCodeConst_1 = require("../../common/const/exitCodeConst");
|
|
56
|
-
const translation_1 = __importDefault(require("../../common/translation/translation"));
|
|
57
|
-
const commonConst_1 = require("../../common/commonConst");
|
|
12
|
+
import ComponentHelper from "./helper/ComponentHelper.js";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import { writeFileSync } from "node:fs";
|
|
15
|
+
import { templateGenerator } from "../../common/helpers/handlebarsHelper.js";
|
|
16
|
+
import * as prompts from "@clack/prompts";
|
|
17
|
+
import { COMPONENT_ERROR } from "../../common/const/exitCodeConst.js";
|
|
18
|
+
import translation from "../../common/translation/translation.js";
|
|
58
19
|
const createSingleComponent = (data, currentDirectory, modulePath) => {
|
|
59
20
|
try {
|
|
60
|
-
const templatePath =
|
|
61
|
-
const output =
|
|
62
|
-
const finalPath =
|
|
63
|
-
|
|
64
|
-
prompts.log.success(`${data.name} ${
|
|
21
|
+
const templatePath = path.join(path.dirname(modulePath), "components", `${data.type}.js.hbs`);
|
|
22
|
+
const output = templateGenerator(templatePath, data);
|
|
23
|
+
const finalPath = path.resolve(currentDirectory, ComponentHelper.normalizeFileName(data.type, data.name));
|
|
24
|
+
writeFileSync(finalPath, output, { encoding: "utf-8" });
|
|
25
|
+
prompts.log.success(`${data.name} ${translation["component.creation.success"]}`);
|
|
65
26
|
}
|
|
66
27
|
catch (e) {
|
|
67
28
|
const simpleMessage = `Failed to create component ${data.name}`;
|
|
68
29
|
const message = e instanceof Error ? `${simpleMessage}: ${e.message}` : simpleMessage;
|
|
69
30
|
prompts.log.error(message);
|
|
70
|
-
process.exit(
|
|
31
|
+
process.exit(COMPONENT_ERROR);
|
|
71
32
|
}
|
|
72
33
|
};
|
|
73
34
|
const createComponent = (componentList) => {
|
|
74
35
|
const currentDirectory = process.cwd();
|
|
75
|
-
const modulePath =
|
|
36
|
+
const modulePath = ComponentHelper.getTemplatePath();
|
|
76
37
|
for (const data of componentList) {
|
|
77
38
|
createSingleComponent(data, currentDirectory, modulePath);
|
|
78
39
|
}
|
|
79
40
|
};
|
|
80
|
-
|
|
41
|
+
export default createComponent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OptionList, SelectionArray } from "../../../common/types/helperTypes";
|
|
1
|
+
import { OptionList, SelectionArray } from "../../../common/types/helperTypes.js";
|
|
2
2
|
declare const ComponentHelper: {
|
|
3
3
|
new (): {};
|
|
4
4
|
readonly selectionFactory: (name: string, options: SelectionArray, message: string) => Promise<string>;
|
|
@@ -8,5 +8,6 @@ declare const ComponentHelper: {
|
|
|
8
8
|
* Manage cancellation with CTRL+C
|
|
9
9
|
*/
|
|
10
10
|
readonly handleCancellation: (value: unknown) => void;
|
|
11
|
+
readonly getTemplatePath: () => string;
|
|
11
12
|
};
|
|
12
13
|
export default ComponentHelper;
|
|
@@ -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,44 +9,13 @@
|
|
|
10
9
|
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
11
10
|
*
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
const prompts = __importStar(require("@clack/prompts"));
|
|
48
|
-
const componentConst_1 = require("../const/componentConst");
|
|
49
|
-
const stringHelper_1 = require("../../../common/helpers/stringHelper");
|
|
50
|
-
const exitCodeConst_1 = require("../../../common/const/exitCodeConst");
|
|
12
|
+
import * as prompts from "@clack/prompts";
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import { RAIL, MENU, TILE_VIEW, SCREEN, SCROLL_VIEW, SCROLL_ITEM, VOD_SCREEN, BUTTON_ITEM_VIEW, } from "../const/componentConst.js";
|
|
15
|
+
import { capitalizeFirstLetter } from "../../../common/helpers/stringHelper.js";
|
|
16
|
+
import { CANCEL } from "../../../common/const/exitCodeConst.js";
|
|
17
|
+
import { TEMPLATE_MODULE } from "../../../common/commonConst.js";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
51
19
|
const ComponentHelper = class {
|
|
52
20
|
static selectionFactory = async (name, options, message) => {
|
|
53
21
|
options = options.map((el) => {
|
|
@@ -72,21 +40,21 @@ const ComponentHelper = class {
|
|
|
72
40
|
return "";
|
|
73
41
|
};
|
|
74
42
|
static normalizeFileName = (type, name) => {
|
|
75
|
-
const uppercaseName =
|
|
43
|
+
const uppercaseName = capitalizeFirstLetter(name);
|
|
76
44
|
switch (type) {
|
|
77
|
-
case
|
|
78
|
-
case
|
|
45
|
+
case RAIL:
|
|
46
|
+
case MENU:
|
|
79
47
|
return `${uppercaseName}ListView.js`;
|
|
80
|
-
case
|
|
48
|
+
case TILE_VIEW:
|
|
81
49
|
return `${uppercaseName}ListItemView.js`;
|
|
82
|
-
case
|
|
50
|
+
case SCROLL_VIEW:
|
|
83
51
|
return `${uppercaseName}ScrollView.js`;
|
|
84
|
-
case
|
|
52
|
+
case SCROLL_ITEM:
|
|
85
53
|
return `${uppercaseName}ScrollItemView.js`;
|
|
86
|
-
case
|
|
87
|
-
case
|
|
54
|
+
case SCREEN:
|
|
55
|
+
case VOD_SCREEN:
|
|
88
56
|
return `${uppercaseName}Screen.js`;
|
|
89
|
-
case
|
|
57
|
+
case BUTTON_ITEM_VIEW:
|
|
90
58
|
return `${uppercaseName}View.js`;
|
|
91
59
|
default:
|
|
92
60
|
return `${uppercaseName}.js`;
|
|
@@ -98,8 +66,12 @@ const ComponentHelper = class {
|
|
|
98
66
|
static handleCancellation = function (value) {
|
|
99
67
|
if (prompts.isCancel(value)) {
|
|
100
68
|
prompts.cancel("Operation cancelled.");
|
|
101
|
-
process.exit(
|
|
69
|
+
process.exit(CANCEL);
|
|
102
70
|
}
|
|
103
71
|
};
|
|
72
|
+
static getTemplatePath = function () {
|
|
73
|
+
const require = createRequire(fileURLToPath(import.meta.url));
|
|
74
|
+
return require.resolve(TEMPLATE_MODULE);
|
|
75
|
+
};
|
|
104
76
|
};
|
|
105
|
-
|
|
77
|
+
export default ComponentHelper;
|
|
@@ -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,117 +9,80 @@
|
|
|
10
9
|
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
11
10
|
*
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 UserInputGetter_1 = __importDefault(require("../../common/helpers/UserInputGetter"));
|
|
51
|
-
const UpdateFileHelper_1 = __importDefault(require("../../common/helpers/UpdateFileHelper"));
|
|
52
|
-
const InstallHelper_1 = __importDefault(require("../../common/helpers/InstallHelper"));
|
|
53
|
-
const CreateAppHelper_1 = __importDefault(require("../createApp/helpers/CreateAppHelper"));
|
|
54
|
-
const CreateFileHelper_1 = __importDefault(require("../../common/helpers/CreateFileHelper"));
|
|
55
|
-
const addDeviceHelper_1 = __importDefault(require("./helper/addDeviceHelper"));
|
|
56
|
-
const prompts = __importStar(require("@clack/prompts"));
|
|
57
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
58
|
-
const picocolors_1 = __importDefault(require("picocolors"));
|
|
59
|
-
const exitCodeConst_1 = require("../../common/const/exitCodeConst");
|
|
60
|
-
const node_process_1 = __importDefault(require("node:process"));
|
|
61
|
-
const translation_1 = __importDefault(require("../../common/translation/translation"));
|
|
62
|
-
const CredentialsHelper_1 = require("../authentication/helper/CredentialsHelper");
|
|
12
|
+
import UserInputGetter from "../../common/helpers/UserInputGetter.js";
|
|
13
|
+
import UpdateFileHelper from "../../common/helpers/UpdateFileHelper.js";
|
|
14
|
+
import InstallHelper from "../../common/helpers/InstallHelper.js";
|
|
15
|
+
import CreateAppHelper from "../createApp/helpers/CreateAppHelper.js";
|
|
16
|
+
import CreateFileHelper from "../../common/helpers/CreateFileHelper.js";
|
|
17
|
+
import AddDeviceHelper from "./helper/addDeviceHelper.js";
|
|
18
|
+
import * as prompts from "@clack/prompts";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import colors from "picocolors";
|
|
21
|
+
import { DEVICE_ERROR } from "../../common/const/exitCodeConst.js";
|
|
22
|
+
import process from "node:process";
|
|
23
|
+
import translation from "../../common/translation/translation.js";
|
|
24
|
+
import { CredentialsHelper } from "../authentication/helper/CredentialsHelper.js";
|
|
63
25
|
const addDevice = async () => {
|
|
64
|
-
prompts.intro(`Add device(s) to ${
|
|
26
|
+
prompts.intro(`Add device(s) to ${path.basename(process.cwd())} !`);
|
|
65
27
|
const data = {};
|
|
66
28
|
try {
|
|
67
29
|
data.directory = "./";
|
|
68
|
-
data.awsProfile =
|
|
69
|
-
const { availableDevices, unavailableDevices } = await
|
|
70
|
-
const installedDevices =
|
|
30
|
+
data.awsProfile = CredentialsHelper.get().org;
|
|
31
|
+
const { availableDevices, unavailableDevices } = await UserInputGetter.getAvailableDevices();
|
|
32
|
+
const installedDevices = AddDeviceHelper.getInstalledDevices(data.directory);
|
|
71
33
|
const filteredAvailableDevices = availableDevices.filter((el) => !installedDevices.includes(el.value));
|
|
72
34
|
if (unavailableDevices.length) {
|
|
73
|
-
|
|
35
|
+
CreateAppHelper.promptUnavailableDevices(unavailableDevices);
|
|
74
36
|
}
|
|
75
37
|
if (filteredAvailableDevices.length) {
|
|
76
|
-
data.selectedDevices = await
|
|
38
|
+
data.selectedDevices = await CreateAppHelper.promptSelectDevices(filteredAvailableDevices);
|
|
77
39
|
}
|
|
78
40
|
if (!data.selectedDevices?.length) {
|
|
79
|
-
prompts.outro(
|
|
41
|
+
prompts.outro(translation["command.device.no_selection"]);
|
|
80
42
|
return;
|
|
81
43
|
}
|
|
82
|
-
data.config = await
|
|
44
|
+
data.config = await UserInputGetter.getDevicesConfig(data);
|
|
83
45
|
}
|
|
84
46
|
catch (e) {
|
|
85
47
|
const message = e instanceof Error ? e.message : e;
|
|
86
|
-
prompts.outro(
|
|
87
|
-
|
|
48
|
+
prompts.outro(colors.red(`An issue occurred :` + message));
|
|
49
|
+
process.exit(DEVICE_ERROR);
|
|
88
50
|
}
|
|
89
51
|
try {
|
|
90
|
-
await
|
|
52
|
+
await CreateAppHelper.installation([
|
|
91
53
|
{
|
|
92
54
|
title: "Update package.json",
|
|
93
|
-
task: async () =>
|
|
55
|
+
task: async () => UpdateFileHelper.updatePackageJson(data),
|
|
94
56
|
},
|
|
95
57
|
{
|
|
96
58
|
title: "Copy app.config files",
|
|
97
|
-
task: async () =>
|
|
59
|
+
task: async () => CreateFileHelper.copyAppConfigFiles(data),
|
|
98
60
|
},
|
|
99
61
|
{
|
|
100
62
|
title: "Update app.config.json",
|
|
101
|
-
task: async () =>
|
|
63
|
+
task: async () => UpdateFileHelper.updateAppConfigFile(data),
|
|
102
64
|
},
|
|
103
65
|
{
|
|
104
66
|
title: "Install dependencies with npm",
|
|
105
|
-
task: async () =>
|
|
67
|
+
task: async () => InstallHelper.installDependencies(data),
|
|
106
68
|
},
|
|
107
69
|
{
|
|
108
70
|
title: "Execute grunt tasks",
|
|
109
|
-
task: async () =>
|
|
71
|
+
task: async () => CreateFileHelper.executeGruntTasks(data),
|
|
110
72
|
},
|
|
111
73
|
{
|
|
112
74
|
title: "Execute devices config",
|
|
113
|
-
task: async () =>
|
|
75
|
+
task: async () => UpdateFileHelper.setDevicesConfig(data),
|
|
114
76
|
},
|
|
115
77
|
]);
|
|
116
78
|
}
|
|
117
79
|
catch (e) {
|
|
118
|
-
|
|
80
|
+
AddDeviceHelper.cleanOnError();
|
|
119
81
|
const message = e instanceof Error ? e.message : e;
|
|
120
|
-
prompts.outro(
|
|
121
|
-
|
|
82
|
+
prompts.outro(colors.red(`${translation["error.common.start.message"]} ${message}`));
|
|
83
|
+
process.exit(DEVICE_ERROR);
|
|
122
84
|
}
|
|
123
85
|
prompts.outro("Everything is ready ! Don't forget to commit your change.");
|
|
124
86
|
return;
|
|
125
87
|
};
|
|
126
|
-
|
|
88
|
+
export default addDevice;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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("../../common/translation/translation"));
|
|
9
|
-
const authHook_1 = require("../authentication/authHook");
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import addDevice from "./add-device.js";
|
|
3
|
+
import translation from "../../common/translation/translation.js";
|
|
4
|
+
import { authHook } from "../authentication/authHook.js";
|
|
10
5
|
const addDeviceDefinition = () => {
|
|
11
|
-
return new
|
|
12
|
-
.description(
|
|
13
|
-
.hook("preAction",
|
|
14
|
-
.action(
|
|
6
|
+
return new Command("add-device")
|
|
7
|
+
.description(translation["command.device.description"])
|
|
8
|
+
.hook("preAction", authHook)
|
|
9
|
+
.action(addDevice);
|
|
15
10
|
};
|
|
16
|
-
|
|
11
|
+
export default addDeviceDefinition;
|