@wiztivi/dana-cli 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dana.js +3 -0
- package/dana_completion.sh +153 -0
- package/dist/commands/add-device.d.ts +2 -0
- package/dist/commands/add-device.js +126 -0
- package/dist/commands/add-menu.d.ts +7 -0
- package/dist/commands/add-menu.js +51 -0
- package/dist/commands/add-rail.d.ts +10 -0
- package/dist/commands/add-rail.js +48 -0
- package/dist/commands/add-screen.d.ts +5 -0
- package/dist/commands/add-screen.js +71 -0
- package/dist/commands/add-scrollView.d.ts +7 -0
- package/dist/commands/add-scrollView.js +37 -0
- package/dist/commands/auth/login.d.ts +5 -0
- package/dist/commands/auth/login.js +141 -0
- package/dist/commands/auth/status.d.ts +11 -0
- package/dist/commands/auth/status.js +76 -0
- package/dist/commands/commandDefinitions/addDeviceDefinition.d.ts +3 -0
- package/dist/commands/commandDefinitions/addDeviceDefinition.js +16 -0
- package/dist/commands/commandDefinitions/addMenuDefinition.d.ts +3 -0
- package/dist/commands/commandDefinitions/addMenuDefinition.js +21 -0
- package/dist/commands/commandDefinitions/addRailDefinition.d.ts +3 -0
- package/dist/commands/commandDefinitions/addRailDefinition.js +31 -0
- package/dist/commands/commandDefinitions/addScreenDefinition.d.ts +3 -0
- package/dist/commands/commandDefinitions/addScreenDefinition.js +18 -0
- package/dist/commands/commandDefinitions/addScrollViewDefinition.d.ts +3 -0
- package/dist/commands/commandDefinitions/addScrollViewDefinition.js +18 -0
- package/dist/commands/commandDefinitions/authDefinition.d.ts +3 -0
- package/dist/commands/commandDefinitions/authDefinition.js +23 -0
- package/dist/commands/commandDefinitions/completionDefinition.d.ts +3 -0
- package/dist/commands/commandDefinitions/completionDefinition.js +17 -0
- package/dist/commands/commandDefinitions/createAppDefinition.d.ts +3 -0
- package/dist/commands/commandDefinitions/createAppDefinition.js +22 -0
- package/dist/commands/completion.d.ts +2 -0
- package/dist/commands/completion.js +84 -0
- package/dist/commands/createApp.d.ts +6 -0
- package/dist/commands/createApp.js +130 -0
- package/dist/commands/createComponent.d.ts +3 -0
- package/dist/commands/createComponent.js +81 -0
- package/dist/commands/help/customHelp.d.ts +3 -0
- package/dist/commands/help/customHelp.js +31 -0
- package/dist/commands/hooks/authHook.d.ts +1 -0
- package/dist/commands/hooks/authHook.js +23 -0
- package/dist/configs/ComponentConfig.d.ts +32 -0
- package/dist/configs/ComponentConfig.js +178 -0
- package/dist/configs/deviceConfig/androidtvConfig.d.ts +37 -0
- package/dist/configs/deviceConfig/androidtvConfig.js +186 -0
- package/dist/configs/deviceConfig/deviceConfig.d.ts +14 -0
- package/dist/configs/deviceConfig/deviceConfig.js +35 -0
- package/dist/configs/deviceConfig/tizenConfig.d.ts +31 -0
- package/dist/configs/deviceConfig/tizenConfig.js +56 -0
- package/dist/configs/deviceConfig/tvosConfig.d.ts +13 -0
- package/dist/configs/deviceConfig/tvosConfig.js +32 -0
- package/dist/configs/deviceConfig/webosConfig.d.ts +59 -0
- package/dist/configs/deviceConfig/webosConfig.js +179 -0
- package/dist/const/authentConst.d.ts +3 -0
- package/dist/const/authentConst.js +6 -0
- package/dist/const/componentConst.d.ts +8 -0
- package/dist/const/componentConst.js +22 -0
- package/dist/const/createApp/deviceConst.d.ts +23 -0
- package/dist/const/createApp/deviceConst.js +73 -0
- package/dist/const/createApp/setupConst.d.ts +3 -0
- package/dist/const/createApp/setupConst.js +18 -0
- package/dist/const/defaultConfig.d.ts +4 -0
- package/dist/const/defaultConfig.js +27 -0
- package/dist/const/exitCodeConst.d.ts +7 -0
- package/dist/const/exitCodeConst.js +10 -0
- package/dist/const/navigationConst.d.ts +3 -0
- package/dist/const/navigationConst.js +36 -0
- package/dist/dana_completion.sh +153 -0
- package/dist/helpers/CliHelper.d.ts +13 -0
- package/dist/helpers/CliHelper.js +39 -0
- package/dist/helpers/CodeArtifactHelper.d.ts +12 -0
- package/dist/helpers/CodeArtifactHelper.js +52 -0
- package/dist/helpers/ComponentHelper.d.ts +12 -0
- package/dist/helpers/ComponentHelper.js +105 -0
- package/dist/helpers/CredentialsHelper.d.ts +27 -0
- package/dist/helpers/CredentialsHelper.js +22 -0
- package/dist/helpers/createApp/CreateFileHelper.d.ts +31 -0
- package/dist/helpers/createApp/CreateFileHelper.js +84 -0
- package/dist/helpers/createApp/InputValidator.d.ts +5 -0
- package/dist/helpers/createApp/InputValidator.js +60 -0
- package/dist/helpers/createApp/InstallHelper.d.ts +30 -0
- package/dist/helpers/createApp/InstallHelper.js +112 -0
- package/dist/helpers/createApp/ScriptHelper.d.ts +116 -0
- package/dist/helpers/createApp/ScriptHelper.js +142 -0
- package/dist/helpers/createApp/SetupChecker.d.ts +25 -0
- package/dist/helpers/createApp/SetupChecker.js +128 -0
- package/dist/helpers/createApp/UpdateFileHelper.d.ts +40 -0
- package/dist/helpers/createApp/UpdateFileHelper.js +121 -0
- package/dist/helpers/createApp/UserInputGetter.d.ts +49 -0
- package/dist/helpers/createApp/UserInputGetter.js +145 -0
- package/dist/helpers/handlebarsHelper.d.ts +2 -0
- package/dist/helpers/handlebarsHelper.js +26 -0
- package/dist/helpers/stringHelper.d.ts +3 -0
- package/dist/helpers/stringHelper.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/program.d.ts +2 -0
- package/dist/program.js +42 -0
- package/dist/translation/en.json +62 -0
- package/dist/translation/translation.d.ts +2 -0
- package/dist/translation/translation.js +8 -0
- package/dist/types/componentTypes.d.ts +31 -0
- package/dist/types/componentTypes.js +2 -0
- package/dist/types/createApp/configTypes.d.ts +27 -0
- package/dist/types/createApp/configTypes.js +13 -0
- package/dist/types/createApp/helperTypes.d.ts +35 -0
- package/dist/types/createApp/helperTypes.js +14 -0
- package/dist/types/genericTypes.d.ts +17 -0
- package/dist/types/genericTypes.js +2 -0
- package/package.json +41 -22
- package/README.md +0 -5
- package/index.js +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
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;
|
|
@@ -0,0 +1,81 @@
|
|
|
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 ComponentHelper_1 = __importDefault(require("../helpers/ComponentHelper"));
|
|
51
|
+
const path_1 = __importDefault(require("path"));
|
|
52
|
+
const fs_1 = require("fs");
|
|
53
|
+
const handlebarsHelper_1 = require("../helpers/handlebarsHelper");
|
|
54
|
+
const prompts = __importStar(require("@clack/prompts"));
|
|
55
|
+
const exitCodeConst_1 = require("../const/exitCodeConst");
|
|
56
|
+
const node_module_1 = require("node:module");
|
|
57
|
+
const translation_1 = __importDefault(require("../translation/translation"));
|
|
58
|
+
const createSingleComponent = (data, currentDirectory, modulePath) => {
|
|
59
|
+
try {
|
|
60
|
+
const templatePath = path_1.default.join(path_1.default.dirname(modulePath), "components", `${data.type}.js.hbs`);
|
|
61
|
+
const output = (0, handlebarsHelper_1.templateGenerator)(templatePath, data);
|
|
62
|
+
const finalPath = path_1.default.resolve(currentDirectory, ComponentHelper_1.default.normalizeFileName(data.type, data.name));
|
|
63
|
+
(0, fs_1.writeFileSync)(finalPath, output, { encoding: "utf-8" });
|
|
64
|
+
prompts.log.success(`${data.name} ${translation_1.default["component.creation.success"]}`);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
const simpleMessage = `Failed to create component ${data.name}`;
|
|
68
|
+
const message = e instanceof Error ? `${simpleMessage}: ${e.message}` : simpleMessage;
|
|
69
|
+
prompts.log.error(message);
|
|
70
|
+
process.exit(exitCodeConst_1.COMPONENT_ERROR);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const createComponent = (componentList) => {
|
|
74
|
+
const currentDirectory = process.cwd();
|
|
75
|
+
const require = (0, node_module_1.createRequire)(currentDirectory);
|
|
76
|
+
const modulePath = require.resolve("@wiztivi/dana-templates");
|
|
77
|
+
for (const data of componentList) {
|
|
78
|
+
createSingleComponent(data, currentDirectory, modulePath);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.default = createComponent;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 deviceConst_1 = require("../../const/createApp/deviceConst");
|
|
7
|
+
const translation_1 = __importDefault(require("../../translation/translation"));
|
|
8
|
+
const customHelp = (program) => {
|
|
9
|
+
const commandList = " " +
|
|
10
|
+
program.commands
|
|
11
|
+
.map((cmd) => `${cmd.name()}: ${cmd.description()}`)
|
|
12
|
+
.sort((a, b) => a.localeCompare(b))
|
|
13
|
+
.join("\n ");
|
|
14
|
+
const availableDevices = Object.values(deviceConst_1.PLATFORM_CONFIG)
|
|
15
|
+
.map((el) => el.label)
|
|
16
|
+
.sort((a, b) => a.localeCompare(b))
|
|
17
|
+
.join(", ");
|
|
18
|
+
return `
|
|
19
|
+
DANA
|
|
20
|
+
===================
|
|
21
|
+
|
|
22
|
+
${translation_1.default["help.custom.commands"]}
|
|
23
|
+
${commandList}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
${translation_1.default["help.custom.devices"]}
|
|
27
|
+
${availableDevices}
|
|
28
|
+
|
|
29
|
+
`;
|
|
30
|
+
};
|
|
31
|
+
exports.default = customHelp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const authHook: () => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.authHook = void 0;
|
|
15
|
+
const status_1 = require("../auth/status");
|
|
16
|
+
const exitCodeConst_1 = require("../../const/exitCodeConst");
|
|
17
|
+
const authHook = () => {
|
|
18
|
+
const isLogged = (0, status_1.status)() === status_1.LOGIN_STATUS.LOGGED;
|
|
19
|
+
if (!isLogged) {
|
|
20
|
+
process.exit(exitCodeConst_1.LOGIN_ERROR);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.authHook = authHook;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RailConfig, MenuConfig, ScreenConfig, ScrollViewConfig } from "../types/componentTypes";
|
|
2
|
+
import { ConfigOptions, OptionList } from "../types/genericTypes";
|
|
3
|
+
interface AskComponentParam {
|
|
4
|
+
componentOption: string;
|
|
5
|
+
optionList: OptionList;
|
|
6
|
+
optionType: string;
|
|
7
|
+
}
|
|
8
|
+
type DefaultConfig = RailConfig | MenuConfig | ScrollViewConfig;
|
|
9
|
+
declare const ComponentConfig: {
|
|
10
|
+
new (): {};
|
|
11
|
+
/**
|
|
12
|
+
* Get component or element name from user
|
|
13
|
+
*/
|
|
14
|
+
readonly askName: (componentType: string, name?: string) => Promise<string>;
|
|
15
|
+
readonly askNumber: (valueType: string, numberValue?: number) => Promise<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Generic function to get option value from command line or user input
|
|
18
|
+
* @param allData
|
|
19
|
+
* @param allData.componentOption - option from command line
|
|
20
|
+
* @param allData.optionList - list of all possible values for the option
|
|
21
|
+
* @param allData.optionType - option type to be used in all prompt messages
|
|
22
|
+
*/
|
|
23
|
+
readonly askComponentOption: (dataOption: AskComponentParam) => Promise<string>;
|
|
24
|
+
readonly askCyclic: (data: ConfigOptions) => Promise<boolean>;
|
|
25
|
+
readonly handlePromptCancel: () => never;
|
|
26
|
+
readonly getDefaultConfig: <T extends DefaultConfig>(data: ConfigOptions, defaultConfig: T) => T;
|
|
27
|
+
readonly railConfig: (data: ConfigOptions) => Promise<RailConfig>;
|
|
28
|
+
readonly menuConfig: (data: ConfigOptions) => Promise<MenuConfig>;
|
|
29
|
+
readonly scrollViewConfig: (data: ConfigOptions) => Promise<ScrollViewConfig>;
|
|
30
|
+
readonly screenConfig: (data: ConfigOptions) => Promise<ScreenConfig>;
|
|
31
|
+
};
|
|
32
|
+
export default ComponentConfig;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
4
|
+
* All Rights Reserved
|
|
5
|
+
*
|
|
6
|
+
* All information contained herein is proprietary and confidential.
|
|
7
|
+
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
8
|
+
* prior written permission is obtained from Wiztivi.
|
|
9
|
+
* No warranty, explicit or implicit, provided.
|
|
10
|
+
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
const prompts = __importStar(require("@clack/prompts"));
|
|
51
|
+
const ComponentHelper_1 = __importDefault(require("../helpers/ComponentHelper"));
|
|
52
|
+
const navigationConst_1 = require("../const/navigationConst");
|
|
53
|
+
const exitCodeConst_1 = require("../const/exitCodeConst");
|
|
54
|
+
const InputValidator_1 = require("../helpers/createApp/InputValidator");
|
|
55
|
+
const defaultConfig_1 = require("../const/defaultConfig");
|
|
56
|
+
const stringHelper_1 = require("../helpers/stringHelper");
|
|
57
|
+
const ComponentConfig = class {
|
|
58
|
+
/**
|
|
59
|
+
* Get component or element name from user
|
|
60
|
+
*/
|
|
61
|
+
static askName = async (componentType, name) => {
|
|
62
|
+
if (!name) {
|
|
63
|
+
const errorMessage = `${componentType} name is mandatory !`;
|
|
64
|
+
name = (await prompts.text({
|
|
65
|
+
message: `${componentType} name`,
|
|
66
|
+
placeholder: "Placeholder Name",
|
|
67
|
+
validate: (value) => (0, InputValidator_1.validInputLength)(value, errorMessage),
|
|
68
|
+
}));
|
|
69
|
+
ComponentHelper_1.default.handleCancellation(name);
|
|
70
|
+
}
|
|
71
|
+
return name.trim();
|
|
72
|
+
};
|
|
73
|
+
static askNumber = async (valueType, numberValue) => {
|
|
74
|
+
const errorMessage = `${valueType} should be a number`;
|
|
75
|
+
const basicMessage = `Enter a value for ${valueType}`;
|
|
76
|
+
const message = numberValue && isNaN(numberValue) ? `${numberValue} is not a number. ${basicMessage}` : basicMessage;
|
|
77
|
+
if (!numberValue || isNaN(numberValue)) {
|
|
78
|
+
const numberValue = (await prompts.text({
|
|
79
|
+
message,
|
|
80
|
+
placeholder: "00",
|
|
81
|
+
validate: (value) => (0, InputValidator_1.validNumber)(value, errorMessage),
|
|
82
|
+
}));
|
|
83
|
+
ComponentHelper_1.default.handleCancellation(numberValue);
|
|
84
|
+
return +numberValue;
|
|
85
|
+
}
|
|
86
|
+
return numberValue;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Generic function to get option value from command line or user input
|
|
90
|
+
* @param allData
|
|
91
|
+
* @param allData.componentOption - option from command line
|
|
92
|
+
* @param allData.optionList - list of all possible values for the option
|
|
93
|
+
* @param allData.optionType - option type to be used in all prompt messages
|
|
94
|
+
*/
|
|
95
|
+
static askComponentOption = async (dataOption) => {
|
|
96
|
+
const { componentOption, optionList, optionType } = dataOption;
|
|
97
|
+
let finalOption = ComponentHelper_1.default.checkOption(componentOption, optionList, optionType);
|
|
98
|
+
if (!finalOption) {
|
|
99
|
+
const selectionMessage = `${(0, stringHelper_1.capitalizeFirstLetter)(optionType)} option`;
|
|
100
|
+
finalOption = await ComponentHelper_1.default.selectionFactory(optionType, optionList, selectionMessage);
|
|
101
|
+
}
|
|
102
|
+
return finalOption;
|
|
103
|
+
};
|
|
104
|
+
static askCyclic = async (data) => {
|
|
105
|
+
if (!data.cyclic) {
|
|
106
|
+
const cyclic = (await prompts.confirm({
|
|
107
|
+
message: "Cyclic list ?",
|
|
108
|
+
}));
|
|
109
|
+
ComponentHelper_1.default.handleCancellation(cyclic);
|
|
110
|
+
return cyclic;
|
|
111
|
+
}
|
|
112
|
+
return data.cyclic;
|
|
113
|
+
};
|
|
114
|
+
static handlePromptCancel = () => {
|
|
115
|
+
prompts.cancel("Operation cancelled.");
|
|
116
|
+
process.exit(exitCodeConst_1.CANCEL);
|
|
117
|
+
};
|
|
118
|
+
static getDefaultConfig = (data, defaultConfig) => {
|
|
119
|
+
return { ...defaultConfig, ...data, addMock: !data.custom };
|
|
120
|
+
};
|
|
121
|
+
static railConfig = async (data) => {
|
|
122
|
+
const config = ComponentConfig.getDefaultConfig(data, defaultConfig_1.RAIL_DEFAULT_CONFIG);
|
|
123
|
+
if (data.custom) {
|
|
124
|
+
const customConfig = await prompts.group({
|
|
125
|
+
name: async () => await this.askName("rail", data.name),
|
|
126
|
+
navigation: async () => await this.askComponentOption({
|
|
127
|
+
componentOption: data.navigation,
|
|
128
|
+
optionList: navigationConst_1.NAVIGATION_TYPES,
|
|
129
|
+
optionType: "navigation",
|
|
130
|
+
}),
|
|
131
|
+
direction: async () => await this.askComponentOption({
|
|
132
|
+
componentOption: data.direction,
|
|
133
|
+
optionList: navigationConst_1.DIRECTION_TYPES,
|
|
134
|
+
optionType: "direction",
|
|
135
|
+
}),
|
|
136
|
+
isCyclic: async () => await this.askCyclic(data),
|
|
137
|
+
itemView: async () => await this.askName("itemView", data.itemView),
|
|
138
|
+
}, { onCancel: () => ComponentConfig.handlePromptCancel() });
|
|
139
|
+
return { ...config, ...customConfig };
|
|
140
|
+
}
|
|
141
|
+
return config;
|
|
142
|
+
};
|
|
143
|
+
static menuConfig = async (data) => {
|
|
144
|
+
const config = ComponentConfig.getDefaultConfig(data, defaultConfig_1.MENU_DEFAULT_CONFIG);
|
|
145
|
+
if (data.custom) {
|
|
146
|
+
const customConfig = await prompts.group({
|
|
147
|
+
name: async () => await this.askName("menu", data.name),
|
|
148
|
+
itemView: async () => await this.askName("itemView", data.itemView),
|
|
149
|
+
itemMargin: async () => await this.askNumber("item margin", data.itemMargin),
|
|
150
|
+
direction: async () => await this.askComponentOption({
|
|
151
|
+
componentOption: data.direction,
|
|
152
|
+
optionList: navigationConst_1.DIRECTION_TYPES,
|
|
153
|
+
optionType: "direction",
|
|
154
|
+
}),
|
|
155
|
+
}, { onCancel: () => ComponentConfig.handlePromptCancel() });
|
|
156
|
+
return { ...config, ...customConfig };
|
|
157
|
+
}
|
|
158
|
+
return config;
|
|
159
|
+
};
|
|
160
|
+
static scrollViewConfig = async (data) => {
|
|
161
|
+
const config = ComponentConfig.getDefaultConfig(data, defaultConfig_1.SCROLLVIEW_DEFAULT_CONFIG);
|
|
162
|
+
if (data.custom) {
|
|
163
|
+
const customConfig = await prompts.group({
|
|
164
|
+
name: async () => await this.askName("scrollView", data.name),
|
|
165
|
+
itemView: async () => await this.askName("itemView", data.itemView),
|
|
166
|
+
itemMargin: async () => await this.askNumber("item margin", data.itemMargin),
|
|
167
|
+
}, { onCancel: () => ComponentConfig.handlePromptCancel() });
|
|
168
|
+
return { ...config, ...customConfig };
|
|
169
|
+
}
|
|
170
|
+
return config;
|
|
171
|
+
};
|
|
172
|
+
static screenConfig = async (data) => {
|
|
173
|
+
return {
|
|
174
|
+
name: data.name ?? (await this.askName("screen")),
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
exports.default = ComponentConfig;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AndroidConfig } from "../../types/createApp/configTypes";
|
|
2
|
+
declare const AndroidtvConfig: {
|
|
3
|
+
new (): {};
|
|
4
|
+
/**
|
|
5
|
+
* Get the app icon url
|
|
6
|
+
*/
|
|
7
|
+
readonly _getAppIcon: () => Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Ask the appId
|
|
10
|
+
*/
|
|
11
|
+
readonly _askAppId: () => Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Ask the appName
|
|
14
|
+
*/
|
|
15
|
+
readonly _askAppName: () => Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Ask the appVersion
|
|
18
|
+
*/
|
|
19
|
+
readonly _askAppVersion: () => Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Ask the appVersion code
|
|
22
|
+
*/
|
|
23
|
+
readonly _askAppVersionCode: () => Promise<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Call aws to get latest android version
|
|
26
|
+
*/
|
|
27
|
+
readonly _getWtvAndroidVersion: () => Promise<string>;
|
|
28
|
+
readonly getConfig: () => Promise<AndroidConfig>;
|
|
29
|
+
readonly setConfig: ({ directory, config, }: {
|
|
30
|
+
directory: string;
|
|
31
|
+
config: AndroidConfig;
|
|
32
|
+
}) => Promise<string>;
|
|
33
|
+
readonly updateProfileJson: (directory: string, config: AndroidConfig) => Promise<string>;
|
|
34
|
+
readonly appConfig: {};
|
|
35
|
+
updateProfileJsonWithRenderers(jsonData: Record<string, unknown>, renderers: string[]): object;
|
|
36
|
+
};
|
|
37
|
+
export default AndroidtvConfig;
|