@wiztivi/dana-cli 0.0.14 → 0.0.16
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/README.md +4 -0
- package/bin/dana.js +1 -1
- package/dana_completion.sh +2 -0
- package/dist/bundle.min.js +2 -0
- package/dist/commands/addComponent/config/ComponentConfig.d.ts +1 -1
- package/dist/commands/addComponent/const/defaultConfig.d.ts +1 -1
- package/dist/commands/addComponent/const/navigationConst.d.ts +1 -1
- package/dist/commands/addComponent/createComponent.d.ts +1 -1
- package/dist/commands/addComponent/helper/ComponentHelper.d.ts +1 -1
- package/dist/commands/addDevice/deviceConfig/configTypes.d.ts +0 -9
- package/dist/commands/addDevice/deviceConfig/webosConfig.d.ts +1 -29
- package/dist/commands/addModule/add-module.d.ts +2 -0
- package/dist/commands/addModule/addModuleDefinition.d.ts +3 -0
- package/dist/commands/addModule/moduleConst.d.ts +10 -0
- package/dist/commands/authentication/AuthenticationManager.d.ts +9 -10
- package/dist/commands/authentication/helper/CodeArtifactHelper.d.ts +1 -1
- package/dist/commands/authentication/helper/CredentialsHelper.d.ts +7 -0
- package/dist/commands/authentication/helper/SPM.d.ts +17 -0
- package/dist/commands/createApp/const/createAppTasks.d.ts +3 -0
- package/dist/commands/createApp/const/templateConst.d.ts +9 -0
- package/dist/commands/createApp/createApp.d.ts +4 -3
- package/dist/commands/createApp/helpers/CreateAppHelper.d.ts +10 -13
- package/dist/commands/createApp/helpers/SetupChecker.d.ts +1 -1
- package/dist/commands/hooks/checkDanaProjectHook.d.ts +2 -0
- package/dist/commands/package/package.d.ts +2 -0
- package/dist/commands/package/packageDefinition.d.ts +3 -0
- package/dist/common/const/exitCodeConst.d.ts +4 -0
- package/dist/common/helpers/CreateArchiveHelper.d.ts +1 -0
- package/dist/common/helpers/CreateFileHelper.d.ts +7 -1
- package/dist/common/helpers/InputValidator.d.ts +1 -1
- package/dist/common/helpers/InstallHelper.d.ts +1 -1
- package/dist/common/helpers/UpdateFileHelper.d.ts +10 -1
- package/dist/common/helpers/UserInputGetter.d.ts +1 -1
- package/dist/common/helpers/stringHelper.d.ts +1 -1
- package/dist/common/types/helperTypes.d.ts +3 -3
- package/package.json +24 -13
- package/dist/commands/addComponent/addMenu/add-menu.js +0 -45
- package/dist/commands/addComponent/addMenu/addMenuDefinition.js +0 -16
- package/dist/commands/addComponent/addRail/add-rail.js +0 -42
- package/dist/commands/addComponent/addRail/addRailDefinition.js +0 -26
- package/dist/commands/addComponent/addScreen/add-screen.js +0 -33
- package/dist/commands/addComponent/addScreen/addScreenDefinition.js +0 -13
- package/dist/commands/addComponent/addScrollView/add-scrollView.js +0 -31
- package/dist/commands/addComponent/addScrollView/addScrollViewDefinition.js +0 -13
- package/dist/commands/addComponent/config/ComponentConfig.js +0 -140
- package/dist/commands/addComponent/config/componentTypes.js +0 -1
- package/dist/commands/addComponent/const/componentConst.js +0 -19
- package/dist/commands/addComponent/const/defaultConfig.js +0 -24
- package/dist/commands/addComponent/const/navigationConst.js +0 -30
- package/dist/commands/addComponent/createComponent.js +0 -41
- package/dist/commands/addComponent/helper/ComponentHelper.js +0 -77
- package/dist/commands/addDevice/add-device.js +0 -90
- package/dist/commands/addDevice/addDeviceDefinition.js +0 -11
- package/dist/commands/addDevice/deviceConfig/androidtvConfig.js +0 -116
- package/dist/commands/addDevice/deviceConfig/configTypes.js +0 -12
- package/dist/commands/addDevice/deviceConfig/deviceConfig.js +0 -33
- package/dist/commands/addDevice/deviceConfig/titanosConfig.js +0 -14
- package/dist/commands/addDevice/deviceConfig/tizenConfig.js +0 -51
- package/dist/commands/addDevice/deviceConfig/tvosConfig.js +0 -45
- package/dist/commands/addDevice/deviceConfig/vidaaConfig.js +0 -14
- package/dist/commands/addDevice/deviceConfig/webosConfig.js +0 -140
- package/dist/commands/addDevice/helper/addDeviceHelper.js +0 -88
- package/dist/commands/authentication/AuthenticationManager.js +0 -167
- package/dist/commands/authentication/authDefinition.js +0 -35
- package/dist/commands/authentication/authHook.js +0 -32
- package/dist/commands/authentication/authentConst.js +0 -6
- package/dist/commands/authentication/commands/get-packages-token.js +0 -30
- package/dist/commands/authentication/commands/login.js +0 -28
- package/dist/commands/authentication/commands/logout.js +0 -20
- package/dist/commands/authentication/commands/status.js +0 -36
- package/dist/commands/authentication/helper/CodeArtifactHelper.js +0 -46
- package/dist/commands/authentication/helper/CommandHelper.js +0 -8
- package/dist/commands/authentication/helper/CredentialsHelper.js +0 -80
- package/dist/commands/commandHelp/customHelp.js +0 -26
- package/dist/commands/completion/completion.js +0 -48
- package/dist/commands/completion/completionDefinition.js +0 -12
- package/dist/commands/createApp/const/setupConst.js +0 -14
- package/dist/commands/createApp/createApp.js +0 -92
- package/dist/commands/createApp/createAppDefinition.js +0 -17
- package/dist/commands/createApp/helpers/CreateAppHelper.js +0 -114
- package/dist/commands/createApp/helpers/SetupChecker.js +0 -90
- package/dist/common/commonConst.js +0 -1
- package/dist/common/const/deviceConst.js +0 -71
- package/dist/common/const/exitCodeConst.js +0 -8
- package/dist/common/helpers/CreateFileHelper.js +0 -95
- package/dist/common/helpers/InputValidator.js +0 -52
- package/dist/common/helpers/InstallHelper.js +0 -145
- package/dist/common/helpers/UpdateFileHelper.js +0 -140
- package/dist/common/helpers/UserInputGetter.js +0 -118
- package/dist/common/helpers/handlebarsHelper.js +0 -21
- package/dist/common/helpers/stringHelper.js +0 -18
- package/dist/common/translation/en.json +0 -68
- package/dist/common/translation/translation.js +0 -3
- package/dist/common/types/helperTypes.js +0 -12
- package/dist/index.js +0 -14
- package/dist/program.js +0 -37
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
-
* All Rights Reserved
|
|
4
|
-
*
|
|
5
|
-
* All information contained herein is proprietary and confidential.
|
|
6
|
-
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
-
* prior written permission is obtained from Wiztivi.
|
|
8
|
-
* No warranty, explicit or implicit, provided.
|
|
9
|
-
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
import { exec, spawn } from "node:child_process";
|
|
13
|
-
import { BASIC_DEPENDENCIES, PLATFORM_CONFIG } from "../const/deviceConst.js";
|
|
14
|
-
import translation from "../translation/translation.js";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import fs from "node:fs";
|
|
17
|
-
class InstallHelper {
|
|
18
|
-
/**
|
|
19
|
-
* Install dependencies with npm
|
|
20
|
-
* @returns {Promise<String>}
|
|
21
|
-
*/
|
|
22
|
-
static installDependencies = ({ directory, selectedDevices, config, }) => {
|
|
23
|
-
const devDependencies = InstallHelper.getDependenciesList(selectedDevices, config);
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
const npmInstall = spawn("npm", ["i", "--silent"], { shell: true, cwd: directory });
|
|
26
|
-
npmInstall.on("close", (code) => {
|
|
27
|
-
if (code === 0) {
|
|
28
|
-
InstallHelper.installSingleDependency(devDependencies, directory)
|
|
29
|
-
.then(() => {
|
|
30
|
-
InstallHelper.updateSemver(directory);
|
|
31
|
-
resolve("Dependencies updated");
|
|
32
|
-
})
|
|
33
|
-
.catch((error) => {
|
|
34
|
-
reject(new Error("Dependencies update failed : " +
|
|
35
|
-
(error.message ?? translation["error.common.start.message"])));
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
reject(new Error("FAILURE during dependencies installation"));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
npmInstall.on("error", (data) => {
|
|
43
|
-
reject(new Error(`FAILURE during dependency installation : ${data}`));
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
static getDependenciesList(selectedDevices, config) {
|
|
48
|
-
let devDependencies = [...BASIC_DEPENDENCIES];
|
|
49
|
-
if (selectedDevices.length) {
|
|
50
|
-
devDependencies = devDependencies.concat(this.getAllDependencies(selectedDevices, config));
|
|
51
|
-
}
|
|
52
|
-
return [...new Set(devDependencies)];
|
|
53
|
-
}
|
|
54
|
-
static installSingleDependency = (depName, directory) => {
|
|
55
|
-
return new Promise((resolveInstall, rejectInstall) => {
|
|
56
|
-
const npmInstall = spawn("npm", ["i", ...depName, "--save-dev", "--save-exact"], {
|
|
57
|
-
cwd: directory,
|
|
58
|
-
shell: true,
|
|
59
|
-
});
|
|
60
|
-
npmInstall.on("close", (code) => {
|
|
61
|
-
if (code === 0) {
|
|
62
|
-
resolveInstall();
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
rejectInstall(new Error(`FAILURE during dependency installation`));
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
npmInstall.on("error", (error) => {
|
|
69
|
-
rejectInstall(new Error(`FAILURE during dependency installation : ${error.message}`));
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
static updateSemver = (directory) => {
|
|
74
|
-
const filePath = path.join(directory, "package.json");
|
|
75
|
-
const packageJson = JSON.parse(fs.readFileSync(filePath).toString());
|
|
76
|
-
packageJson.devDependencies = Object.entries(packageJson.devDependencies).reduce((acc, [key, value]) => {
|
|
77
|
-
acc[key] =
|
|
78
|
-
key.includes("@dana") || key.includes("@wiztivi") ? value.replace(/(\d+\.\d+\.)\d$/, "$1x") : value;
|
|
79
|
-
return acc;
|
|
80
|
-
}, {});
|
|
81
|
-
fs.writeFileSync(filePath, JSON.stringify(packageJson, null, 4));
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Get a list of all dependencies needed by the different devices chosen by user
|
|
85
|
-
*/
|
|
86
|
-
static getAllDependencies = function (selectedDevices, config) {
|
|
87
|
-
let allDep = [];
|
|
88
|
-
for (const el of selectedDevices) {
|
|
89
|
-
allDep = allDep.concat(PLATFORM_CONFIG[el].dependencies);
|
|
90
|
-
}
|
|
91
|
-
for (const key in config) {
|
|
92
|
-
if (Object.hasOwn(config, key)) {
|
|
93
|
-
const obj = config[key];
|
|
94
|
-
const renderer = obj.renderers ?? [];
|
|
95
|
-
for (const r of renderer) {
|
|
96
|
-
allDep = allDep.concat(PLATFORM_CONFIG[key].renderers?.[r] ?? "");
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
allDep = allDep.filter((el) => !!el);
|
|
101
|
-
return allDep;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Install grunt globally
|
|
105
|
-
*/
|
|
106
|
-
static installGrunt = function () {
|
|
107
|
-
return new Promise((resolve) => {
|
|
108
|
-
exec("npm i -g grunt-cli", {}, () => {
|
|
109
|
-
resolve("Grunt installed");
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
static runGitCommand(args, directory) {
|
|
114
|
-
return new Promise((resolve, reject) => {
|
|
115
|
-
const gitProcess = spawn("git", args, { cwd: directory });
|
|
116
|
-
gitProcess.on("close", (code) => {
|
|
117
|
-
if (code === 0) {
|
|
118
|
-
resolve();
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
reject(new Error(`Git ${args[0]} failed`));
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
gitProcess.on("error", (error) => {
|
|
125
|
-
reject(new Error(`Git ${args[0]} failed: ${error.message}`));
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Initialize git repository and do first commit
|
|
131
|
-
* @returns {Promise<String>}
|
|
132
|
-
*/
|
|
133
|
-
static initGit = async function ({ directory }) {
|
|
134
|
-
try {
|
|
135
|
-
await InstallHelper.runGitCommand(["init"], directory);
|
|
136
|
-
await InstallHelper.runGitCommand(["add", "."], directory);
|
|
137
|
-
await InstallHelper.runGitCommand(["commit", "-m", "Initial commit from Create DANA App"], directory);
|
|
138
|
-
return "Git initialized";
|
|
139
|
-
}
|
|
140
|
-
catch (e) {
|
|
141
|
-
throw new Error("Git hasn't been initialised: " + e.message);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
export default InstallHelper;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
-
* All Rights Reserved
|
|
4
|
-
*
|
|
5
|
-
* All information contained herein is proprietary and confidential.
|
|
6
|
-
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
-
* prior written permission is obtained from Wiztivi.
|
|
8
|
-
* No warranty, explicit or implicit, provided.
|
|
9
|
-
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
import fs from "node:fs";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
import CreateAppHelper from "../../commands/createApp/helpers/CreateAppHelper.js";
|
|
15
|
-
import { templateGenerator } from "./handlebarsHelper.js";
|
|
16
|
-
import { CredentialsHelper } from "../../commands/authentication/helper/CredentialsHelper.js";
|
|
17
|
-
import { getRepositoryEndpoint } from "../../commands/authentication/helper/CodeArtifactHelper.js";
|
|
18
|
-
import { REGISTRY_KEY } from "../../commands/createApp/const/setupConst.js";
|
|
19
|
-
import { formatToCamelCase } from "./stringHelper.js";
|
|
20
|
-
class UpdateFileHelper {
|
|
21
|
-
/**
|
|
22
|
-
* Update app.Config files with mandatory Data
|
|
23
|
-
* @returns {Promise}
|
|
24
|
-
*/
|
|
25
|
-
static updateAppConfigFile = function ({ directory }) {
|
|
26
|
-
const dirPath = path.join(directory, "profiles");
|
|
27
|
-
const filePath = path.join(directory, "app.config.json");
|
|
28
|
-
const profileList = fs
|
|
29
|
-
.readdirSync(dirPath, { withFileTypes: true })
|
|
30
|
-
.filter((item) => !item.isDirectory())
|
|
31
|
-
.map((item) => path.join("profiles", item.name));
|
|
32
|
-
const jsonData = JSON.parse(fs.readFileSync(filePath).toString());
|
|
33
|
-
jsonData.includes = profileList;
|
|
34
|
-
fs.writeFileSync(filePath, JSON.stringify(jsonData, null, 4));
|
|
35
|
-
return Promise.resolve("Config file(s) updated");
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Update .npmrc with proper registry key
|
|
39
|
-
*/
|
|
40
|
-
static updateNpmrcFile = async function ({ directory }) {
|
|
41
|
-
const credentials = CredentialsHelper.get();
|
|
42
|
-
const registryAccount = await getRepositoryEndpoint({
|
|
43
|
-
organization: credentials.org,
|
|
44
|
-
credentials: credentials?.aws,
|
|
45
|
-
format: "npm",
|
|
46
|
-
});
|
|
47
|
-
const filePath = path.join(directory, ".npmrc");
|
|
48
|
-
fs.writeFileSync(filePath, `${REGISTRY_KEY}=${registryAccount}`);
|
|
49
|
-
return "AWS profile updated";
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Update package.json with the right project name and add scripts if necessary
|
|
53
|
-
*/
|
|
54
|
-
static updatePackageJson = ({ name, directory, selectedDevices, config, }) => {
|
|
55
|
-
const filePath = path.join(directory, "package.json");
|
|
56
|
-
const packageJson = JSON.parse(fs.readFileSync(filePath).toString());
|
|
57
|
-
if (name) {
|
|
58
|
-
//https://docs.npmjs.com/cli/v10/configuring-npm/package-json?v=true
|
|
59
|
-
const unsafeCharRegex = /[^A-Za-z0-9._-]/g;
|
|
60
|
-
packageJson.name = name.replaceAll(unsafeCharRegex, "").toLowerCase();
|
|
61
|
-
}
|
|
62
|
-
for (const device of selectedDevices) {
|
|
63
|
-
const deviceConfig = config[device];
|
|
64
|
-
if (deviceConfig?.renderers) {
|
|
65
|
-
for (const renderer of deviceConfig.renderers) {
|
|
66
|
-
const profileName = `${device}_${renderer}`;
|
|
67
|
-
packageJson.scripts[`start:${profileName}`] = this.setScriptValue(profileName);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
packageJson.scripts[`start:${device}`] = this.setScriptValue(device);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
fs.writeFileSync(filePath, JSON.stringify(packageJson, null, 4));
|
|
75
|
-
return Promise.resolve("Package updated");
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* set specific configuration for selected devices
|
|
79
|
-
*/
|
|
80
|
-
static setDevicesConfig = async function ({ directory, config, selectedDevices, awsProfile, }) {
|
|
81
|
-
for (const device of selectedDevices) {
|
|
82
|
-
const obj = config[device];
|
|
83
|
-
//@ts-expect-error @typescript-eslint/ban-ts-comment
|
|
84
|
-
await CreateAppHelper.getDeviceConfig(device).setConfig({ directory, awsProfile, config: obj });
|
|
85
|
-
}
|
|
86
|
-
return "Configuration done";
|
|
87
|
-
};
|
|
88
|
-
static setScriptValue = (value) => {
|
|
89
|
-
return `grunt serve --profile=template-${value}`;
|
|
90
|
-
};
|
|
91
|
-
static applyTemplatesToFiles = function ({ directory, name, }) {
|
|
92
|
-
const routesFilePath = path.join(directory, "scripts", "app");
|
|
93
|
-
const appName = `${formatToCamelCase(name)}`;
|
|
94
|
-
const filesToUpdate = [
|
|
95
|
-
{
|
|
96
|
-
fromPath: path.join(routesFilePath, "TemplateAppRoutes.js.hbs"),
|
|
97
|
-
config: { appName },
|
|
98
|
-
toPath: path.join(routesFilePath, `${appName}AppRoutes.js`),
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
fromPath: path.join(routesFilePath, "app.js.hbs"),
|
|
102
|
-
config: { appName },
|
|
103
|
-
toPath: path.join(routesFilePath, "app.js"),
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
fromPath: path.join(directory, "tests", "unit", "app", "TemplateAppRoutes.js.hbs"),
|
|
107
|
-
config: { appName },
|
|
108
|
-
toPath: path.join(directory, "tests", "unit", "app", `${appName}AppRoutes.js`),
|
|
109
|
-
},
|
|
110
|
-
];
|
|
111
|
-
const finalListToUpdate = filesToUpdate.concat(UpdateFileHelper.getConfigFileOutput(directory));
|
|
112
|
-
for (const file of finalListToUpdate) {
|
|
113
|
-
const updatedContent = templateGenerator(file.fromPath, file.config);
|
|
114
|
-
fs.writeFileSync(file.toPath, updatedContent);
|
|
115
|
-
fs.unlink(file.fromPath, (err) => {
|
|
116
|
-
if (err)
|
|
117
|
-
console.error(err);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
return Promise.resolve("Files templated");
|
|
121
|
-
};
|
|
122
|
-
static getConfigFileOutput = function (directory) {
|
|
123
|
-
const configFiles = [
|
|
124
|
-
"gitignoreTemplate.hbs",
|
|
125
|
-
"editorconfigTemplate.hbs",
|
|
126
|
-
"eslintrc.jsonTemplate.hbs",
|
|
127
|
-
"nvmrcTemplate.hbs",
|
|
128
|
-
];
|
|
129
|
-
const filesToUpdate = [];
|
|
130
|
-
for (const configFile of configFiles) {
|
|
131
|
-
filesToUpdate.push({
|
|
132
|
-
fromPath: path.join(directory, configFile),
|
|
133
|
-
config: {},
|
|
134
|
-
toPath: path.join(directory, `.${configFile.replace("Template.hbs", "")}`),
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return filesToUpdate;
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
export default UpdateFileHelper;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
-
* All Rights Reserved
|
|
4
|
-
*
|
|
5
|
-
* All information contained herein is proprietary and confidential.
|
|
6
|
-
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
-
* prior written permission is obtained from Wiztivi.
|
|
8
|
-
* No warranty, explicit or implicit, provided.
|
|
9
|
-
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
import * as prompts from "@clack/prompts";
|
|
13
|
-
import { execSync } from "node:child_process";
|
|
14
|
-
import CreateAppHelper from "../../commands/createApp/helpers/CreateAppHelper.js";
|
|
15
|
-
import { EXTENDED_SETUP, BASIC_SETUP } from "../const/deviceConst.js";
|
|
16
|
-
import { validInputLength } from "./InputValidator.js";
|
|
17
|
-
import translation from "../translation/translation.js";
|
|
18
|
-
import { capitalizeFirstLetter } from "./stringHelper.js";
|
|
19
|
-
class UserInputGetter {
|
|
20
|
-
/**
|
|
21
|
-
* Get project Data from user
|
|
22
|
-
*/
|
|
23
|
-
static getPrompts(argsName, shouldAddDevices) {
|
|
24
|
-
return {
|
|
25
|
-
name: () => this.askProjectName(argsName),
|
|
26
|
-
directory: ({ results }) => this.getProjectDirectory(results.name),
|
|
27
|
-
selectedDevices: () => this.askDevices(shouldAddDevices),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Ask the project name
|
|
32
|
-
*/
|
|
33
|
-
static async askProjectName(name) {
|
|
34
|
-
if (name != null) {
|
|
35
|
-
return UserInputGetter.formatAppName(name);
|
|
36
|
-
}
|
|
37
|
-
const errorMessage = "Project name is mandatory !";
|
|
38
|
-
name = (await prompts.text({
|
|
39
|
-
message: translation["input.name"],
|
|
40
|
-
placeholder: "Placeholder Name",
|
|
41
|
-
validate: (value) => validInputLength(value, errorMessage),
|
|
42
|
-
}));
|
|
43
|
-
CreateAppHelper.handleCancellation(name);
|
|
44
|
-
return UserInputGetter.formatAppName(name);
|
|
45
|
-
}
|
|
46
|
-
static formatAppName(input) {
|
|
47
|
-
const separatorRegex = /[ /]+/;
|
|
48
|
-
return input
|
|
49
|
-
.trim()
|
|
50
|
-
.split(separatorRegex)
|
|
51
|
-
.map((el, index) => (index === 0 ? el : capitalizeFirstLetter(el)))
|
|
52
|
-
.join("");
|
|
53
|
-
}
|
|
54
|
-
static async getProjectDirectory(projectName) {
|
|
55
|
-
return Promise.resolve(`./${projectName}`);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get a list of subscribed and non subscribed devices
|
|
59
|
-
*/
|
|
60
|
-
static getAvailableDevices() {
|
|
61
|
-
const availableDevices = [];
|
|
62
|
-
const unavailableDevices = [];
|
|
63
|
-
const spinner = prompts.spinner();
|
|
64
|
-
spinner.start();
|
|
65
|
-
for (const [key, value] of Object.entries(EXTENDED_SETUP)) {
|
|
66
|
-
try {
|
|
67
|
-
execSync(`npm view ${value.package} --silent`, { encoding: "utf-8" });
|
|
68
|
-
availableDevices.push({ value: key, label: EXTENDED_SETUP[key].label });
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
unavailableDevices.push(EXTENDED_SETUP[key].label);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
spinner.stop("Available devices checked");
|
|
75
|
-
return Promise.resolve({ availableDevices, unavailableDevices });
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Ask for a list of devices
|
|
79
|
-
*/
|
|
80
|
-
static async askDevices(shouldAddDevices) {
|
|
81
|
-
let selectedDevices = this.getBasicDevices();
|
|
82
|
-
if (!shouldAddDevices) {
|
|
83
|
-
return selectedDevices;
|
|
84
|
-
}
|
|
85
|
-
const { availableDevices, unavailableDevices } = await this.getAvailableDevices();
|
|
86
|
-
if (unavailableDevices.length) {
|
|
87
|
-
CreateAppHelper.promptUnavailableDevices(unavailableDevices);
|
|
88
|
-
}
|
|
89
|
-
if (availableDevices.length) {
|
|
90
|
-
const selectObject = {
|
|
91
|
-
message: translation["device.selection"],
|
|
92
|
-
options: availableDevices,
|
|
93
|
-
required: false,
|
|
94
|
-
};
|
|
95
|
-
selectedDevices = selectedDevices.concat((await prompts.multiselect(selectObject)));
|
|
96
|
-
}
|
|
97
|
-
CreateAppHelper.handleCancellation(selectedDevices);
|
|
98
|
-
return selectedDevices;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Get devices natively included in user subscription
|
|
102
|
-
*/
|
|
103
|
-
static getBasicDevices() {
|
|
104
|
-
return Object.keys(BASIC_SETUP);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* get specific configuration for selected devices
|
|
108
|
-
* @returns {Promise<any>}
|
|
109
|
-
*/
|
|
110
|
-
static async getDevicesConfig({ selectedDevices, awsProfile, }) {
|
|
111
|
-
const config = {};
|
|
112
|
-
for (const device of selectedDevices) {
|
|
113
|
-
config[device] = (await CreateAppHelper.getDeviceConfig(device).getConfig(awsProfile));
|
|
114
|
-
}
|
|
115
|
-
return config;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
export default UserInputGetter;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import Handlebars from "handlebars";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { capitalizeFirstLetter } from "./stringHelper.js";
|
|
4
|
-
Handlebars.registerHelper("ifEqTo", (arg1, arg2) => {
|
|
5
|
-
return arg1 === arg2;
|
|
6
|
-
});
|
|
7
|
-
Handlebars.registerHelper("ifNotEqTo", (arg1, arg2) => {
|
|
8
|
-
return arg1 !== arg2;
|
|
9
|
-
});
|
|
10
|
-
Handlebars.registerHelper("normalizeName", (arg1, arg2) => {
|
|
11
|
-
return `${capitalizeFirstLetter(arg1)}${arg2}`;
|
|
12
|
-
});
|
|
13
|
-
Handlebars.registerHelper("capitalize", (arg1) => {
|
|
14
|
-
return capitalizeFirstLetter(arg1);
|
|
15
|
-
});
|
|
16
|
-
function templateGenerator(templatePath, config) {
|
|
17
|
-
const templateString = readFileSync(templatePath, "utf-8");
|
|
18
|
-
const template = Handlebars.compile(templateString);
|
|
19
|
-
return template(config);
|
|
20
|
-
}
|
|
21
|
-
export { templateGenerator };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const capitalizeFirstLetter = (input) => {
|
|
2
|
-
return `${input[0].toUpperCase()}${input.substring(1)}`;
|
|
3
|
-
};
|
|
4
|
-
export const optionsListString = (input) => {
|
|
5
|
-
return input.map((option) => option.command).join(", ");
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Remove separator characters from string and convert it to camelCase
|
|
9
|
-
*/
|
|
10
|
-
export const formatToCamelCase = (input) => {
|
|
11
|
-
const separatorRegex = /[./_\-\\ ]/g;
|
|
12
|
-
return input
|
|
13
|
-
.trim()
|
|
14
|
-
.split(separatorRegex)
|
|
15
|
-
.map((el, index) => (index === 0 ? el.toLowerCase() : formatWordToCamelCase(el)))
|
|
16
|
-
.join("");
|
|
17
|
-
};
|
|
18
|
-
export const formatWordToCamelCase = (input) => `${input[0].toUpperCase()}${input.substring(1).toLowerCase()}`;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"program.usage": "A CLI to help you build dana applications",
|
|
3
|
-
"program.help.footer": "For more information, visit https://doc.dana-framework.com or contact us.",
|
|
4
|
-
"component.creation.success": "component created successfully.",
|
|
5
|
-
"component.creation.error": "Failed to create component",
|
|
6
|
-
"command.rail.description": "Add a rail",
|
|
7
|
-
"command.component.name": "Component's name",
|
|
8
|
-
"command.component.customization": "Full or partial customization. MANDATORY to not use default configuration.",
|
|
9
|
-
"command.rail.option.navigation": "Navigation type. Default: fixed",
|
|
10
|
-
"command.rail.option.direction": "Navigation direction. Default: horizontal",
|
|
11
|
-
"command.rail.option.cyclic": "True if cyclic. Default: false",
|
|
12
|
-
"command.device.description": "Add device(s) to your Dana app",
|
|
13
|
-
"command.device.version.error": "No version found.",
|
|
14
|
-
"command.device.no_selection": "Nothing selected or no device available. Exit",
|
|
15
|
-
"help.custom.devices": "Use the CLI to add the following devices:",
|
|
16
|
-
"help.custom.commands": "Add devices and built-in components to your DANA app:",
|
|
17
|
-
"help.option.title": "Available command options:",
|
|
18
|
-
"help.option.check": "check:",
|
|
19
|
-
"command.menu.description": "Add horizontal menu",
|
|
20
|
-
"command.menu.option.itemView": "Item to be used in the menu",
|
|
21
|
-
"command.menu.option.itemMargin": "Margin between items. Default: 20",
|
|
22
|
-
"helper.git.status.error": "Git status is not clean or an error occurred. Try to commit your change.",
|
|
23
|
-
"command.auth.description": "Authenticate to Dana framework",
|
|
24
|
-
"command.auth.login.description": "Login to Dana",
|
|
25
|
-
"command.auth.logout.description": "Logout from Dana",
|
|
26
|
-
"command.auth.login.option.org": "Organization to login/logout",
|
|
27
|
-
"command.auth.login.option.remote": "Allow connexion to dana authentication stack when working on remote server. Display login url",
|
|
28
|
-
"command.auth.login.option.port": "Provide a port for login server",
|
|
29
|
-
"command.auth.remoteMode": "You are in remote mode. Verify you are forwarding the right port to the host machine.",
|
|
30
|
-
"command.auth.accessBrowserUrl": "You can complete the operation by accessing the following url in the browser.",
|
|
31
|
-
"command.auth.status.description": "Get login status",
|
|
32
|
-
"command.auth.get-packages-token.description": "Get token for packages repository",
|
|
33
|
-
"command.scrollView.description": "Add a scrollView of rails",
|
|
34
|
-
"command.scrollView.option.itemView": "Item to be used in the scrollView. Default: pre-made rail",
|
|
35
|
-
"command.scrollView.option.itemMargin": "Margin between items. Default: 550",
|
|
36
|
-
"command.screen.description": "Add a screen",
|
|
37
|
-
"command.create_app.description": "Create a new Dana app",
|
|
38
|
-
"command.create_app.name": "Project's name",
|
|
39
|
-
"command.create_app.directory": "Project directory",
|
|
40
|
-
"command.create_app.tutorial": "Create project for tutorial",
|
|
41
|
-
"command.create_app.devices": "Add device(s) when creating the project",
|
|
42
|
-
"command.create_app.aws_profile": "Aws profile",
|
|
43
|
-
"command.create_app.aws_repository": "Aws repository provided during registration. Name is XXX in \"dana-XXX-repository\".",
|
|
44
|
-
"task.installation.start": "Installation",
|
|
45
|
-
"task.installation.end": "Installation complete.",
|
|
46
|
-
"creation.final": "Everything is ready.",
|
|
47
|
-
"script.run.title": "Now you can just run:",
|
|
48
|
-
"git.error": "Git is not installed or not available in the PATH. You must install it to continue.",
|
|
49
|
-
"aws.cli.error": "AWS cli is not installed or not available in the PATH. You must install it to continue.",
|
|
50
|
-
"node.error": "Node version should be >=",
|
|
51
|
-
"setup.ok": "Configuration ok",
|
|
52
|
-
"setup.ko": "Prerequisite not met",
|
|
53
|
-
"device.unavailable": "Enhance your experience by adding device(s) to your subscription:",
|
|
54
|
-
"device.selection": "Press SPACE KEY to select additional device(s).",
|
|
55
|
-
"renderer.selection": "Select AT LEAST one renderer for",
|
|
56
|
-
"input.name": "What is your project's name ?",
|
|
57
|
-
"input.aws.error": "You need to have an AWS account.\nSee:https://dana-framework.com/guides/getting-started#configure-aws-connection",
|
|
58
|
-
"input.aws.profile": "Select your AWS profile",
|
|
59
|
-
"aws.login.error": "Please log to AWS before trying again",
|
|
60
|
-
"error.common.start.message": "An error occurred",
|
|
61
|
-
"command.completion.description": "Install shell completion (bash or zsh)",
|
|
62
|
-
"command.completion.argument": "Shell. Bash or zsh",
|
|
63
|
-
"command.completion.success": "Completion installed to ",
|
|
64
|
-
"login.info.token_expired": "Your token has expired.",
|
|
65
|
-
"login.info.please_login": "Please run 'dana auth login' command",
|
|
66
|
-
"login.error.not_logged": "You're not logged in.",
|
|
67
|
-
"login.info.logged": "You're currently logged in to Dana"
|
|
68
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
-
* All Rights Reserved
|
|
4
|
-
*
|
|
5
|
-
* All information contained herein is proprietary and confidential.
|
|
6
|
-
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
-
* prior written permission is obtained from Wiztivi.
|
|
8
|
-
* No warranty, explicit or implicit, provided.
|
|
9
|
-
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
import { ANDROIDTV, TITANOS, TIZEN, TVOS, VIDAA, WEBOS } from "../const/deviceConst.js";
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
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
|
-
import { makeProgram } from "./program.js";
|
|
14
|
-
makeProgram().parse();
|
package/dist/program.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import addDeviceDefinition from "./commands/addDevice/addDeviceDefinition.js";
|
|
5
|
-
import addMenuDefinition from "./commands/addComponent/addMenu/addMenuDefinition.js";
|
|
6
|
-
import addRailDefinition from "./commands/addComponent/addRail/addRailDefinition.js";
|
|
7
|
-
import addScreenDefinition from "./commands/addComponent/addScreen/addScreenDefinition.js";
|
|
8
|
-
import addScrollViewDefinition from "./commands/addComponent/addScrollView/addScrollViewDefinition.js";
|
|
9
|
-
import addAuthDefinition from "./commands/authentication/authDefinition.js";
|
|
10
|
-
import customHelp from "./commands/commandHelp/customHelp.js";
|
|
11
|
-
import translation from "./common/translation/translation.js";
|
|
12
|
-
import createAppDefinition from "./commands/createApp/createAppDefinition.js";
|
|
13
|
-
import completionDefinition from "./commands/completion/completionDefinition.js";
|
|
14
|
-
import { fileURLToPath } from "node:url";
|
|
15
|
-
export const makeProgram = () => {
|
|
16
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
-
const filePath = path.join(__dirname, "..", "package.json");
|
|
18
|
-
const packageJson = JSON.parse(fs.readFileSync(filePath, { encoding: "utf-8" }));
|
|
19
|
-
const program = new Command(packageJson.name);
|
|
20
|
-
program
|
|
21
|
-
.usage(`${translation["program.usage"]}`)
|
|
22
|
-
.version(packageJson.version)
|
|
23
|
-
.addCommand(addRailDefinition())
|
|
24
|
-
.addCommand(addDeviceDefinition())
|
|
25
|
-
.addCommand(addMenuDefinition())
|
|
26
|
-
.addCommand(addAuthDefinition())
|
|
27
|
-
.addCommand(addScrollViewDefinition())
|
|
28
|
-
.addCommand(addScreenDefinition())
|
|
29
|
-
.addCommand(createAppDefinition())
|
|
30
|
-
.addCommand(completionDefinition());
|
|
31
|
-
//help
|
|
32
|
-
program.helpInformation = () => customHelp(program);
|
|
33
|
-
program.addHelpText("afterAll", `
|
|
34
|
-
${translation["program.help.footer"]}
|
|
35
|
-
`);
|
|
36
|
-
return program;
|
|
37
|
-
};
|