@wiztivi/dana-cli 0.0.2-beta-4 → 0.0.4
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/dist/commands/{add-menu.js → addComponent/addMenu/add-menu.js} +12 -13
- package/dist/commands/{commandDefinitions → addComponent/addMenu}/addMenuDefinition.js +2 -2
- package/dist/commands/{add-rail.js → addComponent/addRail/add-rail.js} +9 -10
- package/dist/commands/{commandDefinitions → addComponent/addRail}/addRailDefinition.js +4 -4
- package/dist/commands/{add-screen.js → addComponent/addScreen/add-screen.js} +5 -5
- package/dist/commands/{commandDefinitions → addComponent/addScreen}/addScreenDefinition.js +2 -2
- package/dist/commands/{add-scrollView.js → addComponent/addScrollView/add-scrollView.js} +9 -10
- package/dist/commands/{commandDefinitions → addComponent/addScrollView}/addScrollViewDefinition.js +3 -3
- package/dist/{configs → commands/addComponent/config}/ComponentConfig.d.ts +2 -2
- package/dist/{configs → commands/addComponent/config}/ComponentConfig.js +6 -6
- package/dist/{const → commands/addComponent/const}/defaultConfig.d.ts +1 -1
- package/dist/{const → commands/addComponent/const}/navigationConst.d.ts +1 -1
- package/dist/commands/{createComponent.d.ts → addComponent/createComponent.d.ts} +1 -1
- package/dist/commands/{createComponent.js → addComponent/createComponent.js} +11 -12
- package/dist/{helpers → commands/addComponent/helper}/ComponentHelper.d.ts +1 -1
- package/dist/{helpers → commands/addComponent/helper}/ComponentHelper.js +2 -2
- package/dist/commands/{add-device.js → addDevice/add-device.js} +18 -18
- package/dist/commands/{commandDefinitions → addDevice}/addDeviceDefinition.js +3 -3
- package/dist/{configs → commands/addDevice}/deviceConfig/androidtvConfig.d.ts +1 -1
- package/dist/{configs → commands/addDevice}/deviceConfig/androidtvConfig.js +18 -18
- package/dist/{configs → commands/addDevice}/deviceConfig/deviceConfig.js +2 -2
- package/dist/{configs → commands/addDevice}/deviceConfig/tizenConfig.d.ts +1 -1
- package/dist/{configs → commands/addDevice}/deviceConfig/tizenConfig.js +7 -7
- package/dist/{configs → commands/addDevice}/deviceConfig/tvosConfig.js +6 -6
- package/dist/{configs → commands/addDevice}/deviceConfig/webosConfig.d.ts +2 -2
- package/dist/{configs → commands/addDevice}/deviceConfig/webosConfig.js +11 -12
- package/dist/{helpers/CliHelper.d.ts → commands/addDevice/helper/addDeviceHelper.d.ts} +2 -2
- package/dist/{helpers/CliHelper.js → commands/addDevice/helper/addDeviceHelper.js} +6 -6
- package/dist/commands/{commandDefinitions → authentication}/authDefinition.js +5 -4
- package/dist/commands/{hooks → authentication}/authHook.js +2 -2
- package/dist/{const → commands/authentication}/authentConst.d.ts +1 -0
- package/dist/{const → commands/authentication}/authentConst.js +2 -1
- package/dist/commands/{auth → authentication/commands}/login.js +8 -8
- package/dist/commands/{auth → authentication/commands}/status.js +2 -2
- package/dist/{helpers → commands/authentication/helper}/CodeArtifactHelper.js +2 -2
- package/dist/commands/{help → commandHelp}/customHelp.js +2 -2
- package/dist/commands/{completion.js → completion/completion.js} +7 -7
- package/dist/commands/{commandDefinitions → completion}/completionDefinition.js +2 -2
- package/dist/commands/createApp/const/setupConst.d.ts +3 -0
- package/dist/{const/createApp → commands/createApp/const}/setupConst.js +1 -1
- package/dist/commands/{createApp.js → createApp/createApp.js} +19 -19
- package/dist/commands/{commandDefinitions → createApp}/createAppDefinition.js +3 -3
- package/dist/{helpers/createApp/ScriptHelper.d.ts → commands/createApp/helpers/CreateAppHelper.d.ts} +15 -13
- package/dist/{helpers/createApp/ScriptHelper.js → commands/createApp/helpers/CreateAppHelper.js} +14 -13
- package/dist/{helpers/createApp → commands/createApp/helpers}/SetupChecker.d.ts +1 -1
- package/dist/{helpers/createApp → commands/createApp/helpers}/SetupChecker.js +6 -6
- package/dist/common/commonConst.d.ts +1 -0
- package/dist/common/commonConst.js +4 -0
- package/dist/{helpers/createApp → common/helpers}/CreateFileHelper.d.ts +1 -1
- package/dist/{helpers/createApp → common/helpers}/CreateFileHelper.js +19 -19
- package/dist/{helpers/createApp → common/helpers}/InputValidator.js +1 -1
- package/dist/{helpers/createApp → common/helpers}/InstallHelper.d.ts +1 -1
- package/dist/{helpers/createApp → common/helpers}/InstallHelper.js +14 -12
- package/dist/{helpers/createApp → common/helpers}/UpdateFileHelper.d.ts +1 -1
- package/dist/{helpers/createApp → common/helpers}/UpdateFileHelper.js +39 -33
- package/dist/{helpers/createApp → common/helpers}/UserInputGetter.d.ts +2 -1
- package/dist/{helpers/createApp → common/helpers}/UserInputGetter.js +21 -12
- package/dist/{helpers → common/helpers}/handlebarsHelper.js +2 -2
- package/dist/{helpers → common/helpers}/stringHelper.d.ts +1 -1
- package/dist/{translation → common/translation}/translation.js +1 -1
- package/dist/{types/createApp → common/types}/helperTypes.d.ts +17 -5
- package/dist/{types/createApp → common/types}/helperTypes.js +1 -1
- package/dist/program.js +14 -14
- package/package.json +2 -3
- package/dist/const/createApp/setupConst.d.ts +0 -3
- package/dist/types/genericTypes.d.ts +0 -17
- package/dist/types/genericTypes.js +0 -2
- /package/dist/commands/{add-menu.d.ts → addComponent/addMenu/add-menu.d.ts} +0 -0
- /package/dist/commands/{commandDefinitions → addComponent/addMenu}/addMenuDefinition.d.ts +0 -0
- /package/dist/commands/{add-rail.d.ts → addComponent/addRail/add-rail.d.ts} +0 -0
- /package/dist/commands/{commandDefinitions → addComponent/addRail}/addRailDefinition.d.ts +0 -0
- /package/dist/commands/{add-screen.d.ts → addComponent/addScreen/add-screen.d.ts} +0 -0
- /package/dist/commands/{commandDefinitions → addComponent/addScreen}/addScreenDefinition.d.ts +0 -0
- /package/dist/commands/{add-scrollView.d.ts → addComponent/addScrollView/add-scrollView.d.ts} +0 -0
- /package/dist/commands/{commandDefinitions → addComponent/addScrollView}/addScrollViewDefinition.d.ts +0 -0
- /package/dist/{types → commands/addComponent/config}/componentTypes.d.ts +0 -0
- /package/dist/{types → commands/addComponent/config}/componentTypes.js +0 -0
- /package/dist/{const → commands/addComponent/const}/componentConst.d.ts +0 -0
- /package/dist/{const → commands/addComponent/const}/componentConst.js +0 -0
- /package/dist/{const → commands/addComponent/const}/defaultConfig.js +0 -0
- /package/dist/{const → commands/addComponent/const}/navigationConst.js +0 -0
- /package/dist/commands/{add-device.d.ts → addDevice/add-device.d.ts} +0 -0
- /package/dist/commands/{commandDefinitions → addDevice}/addDeviceDefinition.d.ts +0 -0
- /package/dist/{types/createApp → commands/addDevice/deviceConfig}/configTypes.d.ts +0 -0
- /package/dist/{types/createApp → commands/addDevice/deviceConfig}/configTypes.js +0 -0
- /package/dist/{configs → commands/addDevice}/deviceConfig/deviceConfig.d.ts +0 -0
- /package/dist/{configs → commands/addDevice}/deviceConfig/tvosConfig.d.ts +0 -0
- /package/dist/commands/{commandDefinitions → authentication}/authDefinition.d.ts +0 -0
- /package/dist/commands/{hooks → authentication}/authHook.d.ts +0 -0
- /package/dist/commands/{auth → authentication/commands}/login.d.ts +0 -0
- /package/dist/commands/{auth → authentication/commands}/status.d.ts +0 -0
- /package/dist/{helpers → commands/authentication/helper}/CodeArtifactHelper.d.ts +0 -0
- /package/dist/{helpers → commands/authentication/helper}/CredentialsHelper.d.ts +0 -0
- /package/dist/{helpers → commands/authentication/helper}/CredentialsHelper.js +0 -0
- /package/dist/commands/{help → commandHelp}/customHelp.d.ts +0 -0
- /package/dist/commands/{completion.d.ts → completion/completion.d.ts} +0 -0
- /package/dist/commands/{commandDefinitions → completion}/completionDefinition.d.ts +0 -0
- /package/dist/commands/{createApp.d.ts → createApp/createApp.d.ts} +0 -0
- /package/dist/commands/{commandDefinitions → createApp}/createAppDefinition.d.ts +0 -0
- /package/dist/{const/createApp → common/const}/deviceConst.d.ts +0 -0
- /package/dist/{const/createApp → common/const}/deviceConst.js +0 -0
- /package/dist/{const → common/const}/exitCodeConst.d.ts +0 -0
- /package/dist/{const → common/const}/exitCodeConst.js +0 -0
- /package/dist/{helpers/createApp → common/helpers}/InputValidator.d.ts +0 -0
- /package/dist/{helpers → common/helpers}/handlebarsHelper.d.ts +0 -0
- /package/dist/{helpers → common/helpers}/stringHelper.js +0 -0
- /package/dist/{translation → common/translation}/en.json +0 -0
- /package/dist/{translation → common/translation}/translation.d.ts +0 -0
|
@@ -14,44 +14,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
19
19
|
const node_child_process_1 = require("node:child_process");
|
|
20
|
-
const deviceConst_1 = require("
|
|
21
|
-
const translation_1 = __importDefault(require("
|
|
22
|
-
const CredentialsHelper_1 = require("
|
|
23
|
-
const CodeArtifactHelper_1 = require("
|
|
24
|
-
const
|
|
20
|
+
const deviceConst_1 = require("../const/deviceConst");
|
|
21
|
+
const translation_1 = __importDefault(require("../translation/translation"));
|
|
22
|
+
const CredentialsHelper_1 = require("../../commands/authentication/helper/CredentialsHelper");
|
|
23
|
+
const CodeArtifactHelper_1 = require("../../commands/authentication/helper/CodeArtifactHelper");
|
|
24
|
+
const commonConst_1 = require("../commonConst");
|
|
25
25
|
class CreateFileHelper {
|
|
26
26
|
/**
|
|
27
27
|
* Copy the template
|
|
28
28
|
*/
|
|
29
29
|
static copyTemplate = function ({ directory }) {
|
|
30
|
-
const templateDir =
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const templateDir = node_path_1.default.resolve(node_path_1.default.dirname(require.resolve(commonConst_1.TEMPLATE_MODULE)), "app-template");
|
|
31
|
+
node_fs_1.default.mkdirSync(directory, { recursive: true });
|
|
32
|
+
node_fs_1.default.cpSync(templateDir, directory, { recursive: true });
|
|
33
33
|
return Promise.resolve("Template copied");
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* Copy made for extra tutorial files
|
|
37
37
|
*/
|
|
38
38
|
static copyForTutorial = function ({ directory }) {
|
|
39
|
-
const templateDir =
|
|
40
|
-
|
|
39
|
+
const templateDir = node_path_1.default.resolve(node_path_1.default.dirname(require.resolve(commonConst_1.TEMPLATE_MODULE)), "tutorial");
|
|
40
|
+
node_fs_1.default.cpSync(templateDir, directory, { recursive: true });
|
|
41
41
|
return Promise.resolve("Tutorial files copied");
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Copy app.config files for selected devices
|
|
45
45
|
*/
|
|
46
46
|
static copyAppConfigFiles = function ({ selectedDevices, directory, }) {
|
|
47
|
-
const templateDir =
|
|
48
|
-
const allFiles =
|
|
49
|
-
|
|
47
|
+
const templateDir = node_path_1.default.resolve(node_path_1.default.dirname(require.resolve(commonConst_1.TEMPLATE_MODULE)), "profiles");
|
|
48
|
+
const allFiles = node_fs_1.default.readdirSync(templateDir);
|
|
49
|
+
for (const file of allFiles) {
|
|
50
50
|
const shouldCopy = selectedDevices.includes(file.split(".")[2]);
|
|
51
51
|
if (shouldCopy) {
|
|
52
|
-
|
|
52
|
+
node_fs_1.default.cpSync(node_path_1.default.join(templateDir, file), node_path_1.default.join(directory, "profiles", file));
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
return Promise.resolve("Config file(s) copied");
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
@@ -75,10 +75,10 @@ class CreateFileHelper {
|
|
|
75
75
|
}
|
|
76
76
|
catch (e) {
|
|
77
77
|
const message = e instanceof Error ? e.message : translation_1.default["error.common.start.message"];
|
|
78
|
-
|
|
78
|
+
throw new Error(message);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
return
|
|
81
|
+
return "Grunt task(s) done";
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
exports.default = CreateFileHelper;
|
|
@@ -14,9 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
const
|
|
18
|
-
const deviceConst_1 = require("
|
|
19
|
-
const translation_1 = __importDefault(require("
|
|
17
|
+
const node_child_process_1 = require("node:child_process");
|
|
18
|
+
const deviceConst_1 = require("../const/deviceConst");
|
|
19
|
+
const translation_1 = __importDefault(require("../translation/translation"));
|
|
20
20
|
class InstallHelper {
|
|
21
21
|
/**
|
|
22
22
|
* Install dependencies with npm
|
|
@@ -25,7 +25,7 @@ class InstallHelper {
|
|
|
25
25
|
static installDependencies = ({ directory, selectedDevices, config, }) => {
|
|
26
26
|
const devDependencies = InstallHelper.getDependenciesList(selectedDevices, config);
|
|
27
27
|
return new Promise((resolve, reject) => {
|
|
28
|
-
(0,
|
|
28
|
+
(0, node_child_process_1.exec)(`npm i --prefix ${directory} --silent`, {}, (async () => {
|
|
29
29
|
try {
|
|
30
30
|
for (const depName of devDependencies) {
|
|
31
31
|
await InstallHelper.installSingleDependency(depName, directory);
|
|
@@ -48,8 +48,8 @@ class InstallHelper {
|
|
|
48
48
|
}
|
|
49
49
|
static installSingleDependency = (depName, directory) => {
|
|
50
50
|
return new Promise((resolveInstall, rejectInstall) => {
|
|
51
|
-
(0,
|
|
52
|
-
if (error
|
|
51
|
+
(0, node_child_process_1.exec)(`npm i ${depName} --prefix '${directory}' --save-dev --save-exact`, {}, (error) => {
|
|
52
|
+
if (error) {
|
|
53
53
|
rejectInstall(new Error(`FAILURE during ${depName} dependency installation ${error.message}`));
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
@@ -63,14 +63,16 @@ class InstallHelper {
|
|
|
63
63
|
*/
|
|
64
64
|
static getAllDependencies = function (selectedDevices, config) {
|
|
65
65
|
let allDep = [];
|
|
66
|
-
|
|
66
|
+
for (const el of selectedDevices) {
|
|
67
67
|
allDep = allDep.concat(deviceConst_1.PLATFORM_CONFIG[el].dependencies);
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
69
|
for (const key in config) {
|
|
70
70
|
if (Object.hasOwn(config, key)) {
|
|
71
71
|
const obj = config[key];
|
|
72
72
|
const renderer = obj.renderers ?? [];
|
|
73
|
-
|
|
73
|
+
for (const r of renderer) {
|
|
74
|
+
allDep = allDep.concat(deviceConst_1.PLATFORM_CONFIG[key].renderers?.[r] ?? "");
|
|
75
|
+
}
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
allDep = allDep.filter((el) => !!el);
|
|
@@ -81,7 +83,7 @@ class InstallHelper {
|
|
|
81
83
|
*/
|
|
82
84
|
static installGrunt = function () {
|
|
83
85
|
return new Promise((resolve) => {
|
|
84
|
-
(0,
|
|
86
|
+
(0, node_child_process_1.exec)("npm i -g grunt-cli", {}, () => {
|
|
85
87
|
resolve("Grunt installed");
|
|
86
88
|
});
|
|
87
89
|
});
|
|
@@ -93,9 +95,9 @@ class InstallHelper {
|
|
|
93
95
|
static initGit = function ({ directory }) {
|
|
94
96
|
return new Promise((resolve, reject) => {
|
|
95
97
|
try {
|
|
96
|
-
(0,
|
|
98
|
+
(0, node_child_process_1.exec)(`cd ${directory} && git init && git add -A && git commit -m "Initial commit from Create DANA App"`, { maxBuffer: 1024 * 1024 * 64 }, // 64MB
|
|
97
99
|
(error) => {
|
|
98
|
-
if (error
|
|
100
|
+
if (error) {
|
|
99
101
|
reject(error);
|
|
100
102
|
}
|
|
101
103
|
else {
|
|
@@ -14,27 +14,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const handlebarsHelper_1 = require("
|
|
21
|
-
const CredentialsHelper_1 = require("
|
|
22
|
-
const CodeArtifactHelper_1 = require("
|
|
17
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
19
|
+
const CreateAppHelper_1 = __importDefault(require("../../commands/createApp/helpers/CreateAppHelper"));
|
|
20
|
+
const handlebarsHelper_1 = require("./handlebarsHelper");
|
|
21
|
+
const CredentialsHelper_1 = require("../../commands/authentication/helper/CredentialsHelper");
|
|
22
|
+
const CodeArtifactHelper_1 = require("../../commands/authentication/helper/CodeArtifactHelper");
|
|
23
|
+
const setupConst_1 = require("../../commands/createApp/const/setupConst");
|
|
23
24
|
class UpdateFileHelper {
|
|
24
25
|
/**
|
|
25
26
|
* Update app.Config files with mandatory Data
|
|
26
27
|
* @returns {Promise}
|
|
27
28
|
*/
|
|
28
29
|
static updateAppConfigFile = function ({ directory }) {
|
|
29
|
-
const dirPath =
|
|
30
|
-
const filePath =
|
|
31
|
-
const profileList =
|
|
30
|
+
const dirPath = node_path_1.default.join(directory, "profiles");
|
|
31
|
+
const filePath = node_path_1.default.join(directory, "app.config.json");
|
|
32
|
+
const profileList = node_fs_1.default
|
|
32
33
|
.readdirSync(dirPath, { withFileTypes: true })
|
|
33
34
|
.filter((item) => !item.isDirectory())
|
|
34
|
-
.map((item) =>
|
|
35
|
-
const jsonData = JSON.parse(
|
|
35
|
+
.map((item) => node_path_1.default.join("profiles", item.name));
|
|
36
|
+
const jsonData = JSON.parse(node_fs_1.default.readFileSync(filePath).toString());
|
|
36
37
|
jsonData.includes = profileList;
|
|
37
|
-
|
|
38
|
+
node_fs_1.default.writeFileSync(filePath, JSON.stringify(jsonData, null, 4));
|
|
38
39
|
return Promise.resolve("Config file(s) updated");
|
|
39
40
|
};
|
|
40
41
|
/**
|
|
@@ -47,32 +48,32 @@ class UpdateFileHelper {
|
|
|
47
48
|
credentials: credentials?.aws,
|
|
48
49
|
format: "npm",
|
|
49
50
|
});
|
|
50
|
-
const filePath =
|
|
51
|
-
|
|
52
|
-
return
|
|
51
|
+
const filePath = node_path_1.default.join(directory, ".npmrc");
|
|
52
|
+
node_fs_1.default.writeFileSync(filePath, `${setupConst_1.REGISTRY_KEY}=${registryAccount}`);
|
|
53
|
+
return "AWS profile updated";
|
|
53
54
|
};
|
|
54
55
|
/**
|
|
55
56
|
* Update package.json with the right project name and add scripts if necessary
|
|
56
57
|
*/
|
|
57
58
|
static updatePackageJson = ({ name, directory, selectedDevices, config, }) => {
|
|
58
|
-
const filePath =
|
|
59
|
-
const packageJson = JSON.parse(
|
|
59
|
+
const filePath = node_path_1.default.join(directory, "package.json");
|
|
60
|
+
const packageJson = JSON.parse(node_fs_1.default.readFileSync(filePath).toString());
|
|
60
61
|
if (name) {
|
|
61
62
|
packageJson.name = name;
|
|
62
63
|
}
|
|
63
64
|
for (const device of selectedDevices) {
|
|
64
65
|
const deviceConfig = config[device];
|
|
65
66
|
if (deviceConfig?.renderers) {
|
|
66
|
-
deviceConfig.renderers
|
|
67
|
+
for (const renderer of deviceConfig.renderers) {
|
|
67
68
|
const profileName = `${device}_${renderer}`;
|
|
68
69
|
packageJson.scripts[`start:${profileName}`] = this.setScriptValue(profileName);
|
|
69
|
-
}
|
|
70
|
+
}
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
72
73
|
packageJson.scripts[`start:${device}`] = this.setScriptValue(device);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
node_fs_1.default.writeFileSync(filePath, JSON.stringify(packageJson, null, 4));
|
|
76
77
|
return Promise.resolve("Package updated");
|
|
77
78
|
};
|
|
78
79
|
/**
|
|
@@ -82,41 +83,46 @@ class UpdateFileHelper {
|
|
|
82
83
|
for (const device of selectedDevices) {
|
|
83
84
|
const obj = config[device];
|
|
84
85
|
//@ts-expect-error @typescript-eslint/ban-ts-comment
|
|
85
|
-
await
|
|
86
|
+
await CreateAppHelper_1.default.getDeviceConfig(device).setConfig({ directory, awsProfile, config: obj });
|
|
86
87
|
}
|
|
87
|
-
return
|
|
88
|
+
return "Configuration done";
|
|
88
89
|
};
|
|
89
90
|
static setScriptValue = (value) => {
|
|
90
91
|
return `grunt serve --profile=template-${value}`;
|
|
91
92
|
};
|
|
92
93
|
static applyTemplatesToFiles = function ({ directory, name, }) {
|
|
93
|
-
const routesFilePath =
|
|
94
|
+
const routesFilePath = node_path_1.default.join(directory, "scripts", "app");
|
|
94
95
|
const appName = `${name[0].toUpperCase()}${name.substring(1)}`;
|
|
95
96
|
const filesToUpdate = [
|
|
96
97
|
{
|
|
97
|
-
fromPath:
|
|
98
|
+
fromPath: node_path_1.default.join(routesFilePath, "TemplateAppRoutes.js.hbs"),
|
|
98
99
|
config: { appName },
|
|
99
|
-
toPath:
|
|
100
|
+
toPath: node_path_1.default.join(routesFilePath, `${appName}AppRoutes.js`),
|
|
100
101
|
},
|
|
101
102
|
{
|
|
102
|
-
fromPath:
|
|
103
|
+
fromPath: node_path_1.default.join(routesFilePath, "app.js.hbs"),
|
|
103
104
|
config: { appName },
|
|
104
|
-
toPath:
|
|
105
|
+
toPath: node_path_1.default.join(routesFilePath, "app.js"),
|
|
105
106
|
},
|
|
106
107
|
{
|
|
107
|
-
fromPath:
|
|
108
|
+
fromPath: node_path_1.default.join(directory, "tests", "unit", "app", "TemplateAppRoutes.js.hbs"),
|
|
108
109
|
config: { appName },
|
|
109
|
-
toPath:
|
|
110
|
+
toPath: node_path_1.default.join(directory, "tests", "unit", "app", `${appName}AppRoutes.js`),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
fromPath: node_path_1.default.join(directory, "gitignoreTemplate.hbs"),
|
|
114
|
+
config: {},
|
|
115
|
+
toPath: node_path_1.default.join(directory, `.gitignore`),
|
|
110
116
|
},
|
|
111
117
|
];
|
|
112
|
-
|
|
118
|
+
for (const file of filesToUpdate) {
|
|
113
119
|
const updatedContent = (0, handlebarsHelper_1.templateGenerator)(file.fromPath, file.config);
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
node_fs_1.default.writeFileSync(file.toPath, updatedContent);
|
|
121
|
+
node_fs_1.default.unlink(file.fromPath, (err) => {
|
|
116
122
|
if (err)
|
|
117
123
|
console.error(err);
|
|
118
124
|
});
|
|
119
|
-
}
|
|
125
|
+
}
|
|
120
126
|
return Promise.resolve("Files templated");
|
|
121
127
|
};
|
|
122
128
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config } from "
|
|
1
|
+
import { Config } from "../types/helperTypes";
|
|
2
2
|
type SelectionArray = {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|
|
@@ -21,6 +21,7 @@ declare class UserInputGetter {
|
|
|
21
21
|
* Ask the project name
|
|
22
22
|
*/
|
|
23
23
|
static askProjectName(name?: string): Promise<string>;
|
|
24
|
+
static formatAppName(input: string): string;
|
|
24
25
|
static getProjectDirectory(projectName: string): Promise<string>;
|
|
25
26
|
/**
|
|
26
27
|
* Get a list of subscribed and non subscribed devices
|
|
@@ -48,11 +48,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
const prompts = __importStar(require("@clack/prompts"));
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const deviceConst_1 = require("
|
|
51
|
+
const node_child_process_1 = require("node:child_process");
|
|
52
|
+
const CreateAppHelper_1 = __importDefault(require("../../commands/createApp/helpers/CreateAppHelper"));
|
|
53
|
+
const deviceConst_1 = require("../const/deviceConst");
|
|
54
54
|
const InputValidator_1 = require("./InputValidator");
|
|
55
|
-
const translation_1 = __importDefault(require("
|
|
55
|
+
const translation_1 = __importDefault(require("../translation/translation"));
|
|
56
|
+
const stringHelper_1 = require("./stringHelper");
|
|
56
57
|
class UserInputGetter {
|
|
57
58
|
/**
|
|
58
59
|
* Get project Data from user
|
|
@@ -69,7 +70,7 @@ class UserInputGetter {
|
|
|
69
70
|
*/
|
|
70
71
|
static async askProjectName(name) {
|
|
71
72
|
if (name != null) {
|
|
72
|
-
return
|
|
73
|
+
return UserInputGetter.formatAppName(name);
|
|
73
74
|
}
|
|
74
75
|
const errorMessage = "Project name is mandatory !";
|
|
75
76
|
name = (await prompts.text({
|
|
@@ -77,8 +78,16 @@ class UserInputGetter {
|
|
|
77
78
|
placeholder: "Placeholder Name",
|
|
78
79
|
validate: (value) => (0, InputValidator_1.validInputLength)(value, errorMessage),
|
|
79
80
|
}));
|
|
80
|
-
|
|
81
|
-
return
|
|
81
|
+
CreateAppHelper_1.default.handleCancellation(name);
|
|
82
|
+
return UserInputGetter.formatAppName(name);
|
|
83
|
+
}
|
|
84
|
+
static formatAppName(input) {
|
|
85
|
+
const separatorRegex = /[ \-_.]+/;
|
|
86
|
+
return input
|
|
87
|
+
.trim()
|
|
88
|
+
.split(separatorRegex)
|
|
89
|
+
.map((el, index) => (index === 0 ? el : (0, stringHelper_1.capitalizeFirstLetter)(el)))
|
|
90
|
+
.join("");
|
|
82
91
|
}
|
|
83
92
|
static async getProjectDirectory(projectName) {
|
|
84
93
|
return Promise.resolve(`./${projectName}`);
|
|
@@ -91,7 +100,7 @@ class UserInputGetter {
|
|
|
91
100
|
const unavailableDevices = [];
|
|
92
101
|
for (const [key, value] of Object.entries(deviceConst_1.EXTENDED_SETUP)) {
|
|
93
102
|
try {
|
|
94
|
-
(0,
|
|
103
|
+
(0, node_child_process_1.execSync)(`npm view ${value.package} --silent`, { encoding: "utf-8" });
|
|
95
104
|
availableDevices.push({ value: key, label: deviceConst_1.EXTENDED_SETUP[key].label });
|
|
96
105
|
}
|
|
97
106
|
catch {
|
|
@@ -110,7 +119,7 @@ class UserInputGetter {
|
|
|
110
119
|
}
|
|
111
120
|
const { availableDevices, unavailableDevices } = await this.getAvailableDevices();
|
|
112
121
|
if (unavailableDevices.length) {
|
|
113
|
-
|
|
122
|
+
CreateAppHelper_1.default.promptUnavailableDevices(unavailableDevices);
|
|
114
123
|
}
|
|
115
124
|
if (availableDevices.length) {
|
|
116
125
|
const selectObject = {
|
|
@@ -120,7 +129,7 @@ class UserInputGetter {
|
|
|
120
129
|
};
|
|
121
130
|
selectedDevices = selectedDevices.concat((await prompts.multiselect(selectObject)));
|
|
122
131
|
}
|
|
123
|
-
|
|
132
|
+
CreateAppHelper_1.default.handleCancellation(selectedDevices);
|
|
124
133
|
return selectedDevices;
|
|
125
134
|
}
|
|
126
135
|
/**
|
|
@@ -136,9 +145,9 @@ class UserInputGetter {
|
|
|
136
145
|
static async getDevicesConfig({ selectedDevices, awsProfile, }) {
|
|
137
146
|
const config = {};
|
|
138
147
|
for (const device of selectedDevices) {
|
|
139
|
-
config[device] = (await
|
|
148
|
+
config[device] = (await CreateAppHelper_1.default.getDeviceConfig(device).getConfig(awsProfile));
|
|
140
149
|
}
|
|
141
|
-
return
|
|
150
|
+
return config;
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
153
|
exports.default = UserInputGetter;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.templateGenerator = templateGenerator;
|
|
7
7
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
8
|
-
const
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
9
|
const stringHelper_1 = require("./stringHelper");
|
|
10
10
|
handlebars_1.default.registerHelper("ifEqTo", (arg1, arg2) => {
|
|
11
11
|
return arg1 === arg2;
|
|
@@ -20,7 +20,7 @@ handlebars_1.default.registerHelper("capitalize", (arg1) => {
|
|
|
20
20
|
return (0, stringHelper_1.capitalizeFirstLetter)(arg1);
|
|
21
21
|
});
|
|
22
22
|
function templateGenerator(templatePath, config) {
|
|
23
|
-
const templateString = (0,
|
|
23
|
+
const templateString = (0, node_fs_1.readFileSync)(templatePath, "utf-8");
|
|
24
24
|
const template = handlebars_1.default.compile(templateString);
|
|
25
25
|
return template(config);
|
|
26
26
|
}
|
|
@@ -3,6 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const en_json_1 = __importDefault(require("
|
|
6
|
+
const en_json_1 = __importDefault(require("./en.json"));
|
|
7
7
|
const translation = en_json_1.default;
|
|
8
8
|
exports.default = translation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ANDROIDTV, TIZEN, TVOS, WEBOS } from "
|
|
2
|
-
import { AndroidConfig, AndroidDevice, TizenConf, WebosConf, WebosDevice } from "
|
|
1
|
+
import { ANDROIDTV, TIZEN, TVOS, WEBOS } from "../const/deviceConst";
|
|
2
|
+
import { AndroidConfig, AndroidDevice, TizenConf, WebosConf, WebosDevice } from "../../commands/addDevice/deviceConfig/configTypes";
|
|
3
3
|
interface Task {
|
|
4
4
|
title: string;
|
|
5
5
|
task: () => Promise<string>;
|
|
@@ -23,13 +23,25 @@ interface DeviceConf {
|
|
|
23
23
|
renderers?: string[];
|
|
24
24
|
}
|
|
25
25
|
type JsonType = Record<string, unknown>;
|
|
26
|
-
|
|
26
|
+
interface SelectionItem {
|
|
27
27
|
value: string;
|
|
28
28
|
label: string;
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
|
+
type SelectionArray = SelectionItem[];
|
|
30
31
|
interface SelectObject {
|
|
31
32
|
message: string;
|
|
32
33
|
options: SelectionArray;
|
|
33
34
|
required: boolean;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
type ConfigOptions = {
|
|
37
|
+
cyclic?: boolean;
|
|
38
|
+
itemMargin?: number;
|
|
39
|
+
custom?: boolean;
|
|
40
|
+
} & Record<string, string>;
|
|
41
|
+
interface OptionItem {
|
|
42
|
+
label: string;
|
|
43
|
+
value: string;
|
|
44
|
+
command: string;
|
|
45
|
+
}
|
|
46
|
+
type OptionList = OptionItem[];
|
|
47
|
+
export { Task, Data, Config, DeviceConf, JsonType, SelectObject, SelectionArray, ConfigOptions, OptionList };
|
package/dist/program.js
CHANGED
|
@@ -5,21 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeProgram = void 0;
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const addDeviceDefinition_1 = __importDefault(require("./commands/
|
|
11
|
-
const addMenuDefinition_1 = __importDefault(require("./commands/
|
|
12
|
-
const addRailDefinition_1 = __importDefault(require("./commands/
|
|
13
|
-
const addScreenDefinition_1 = __importDefault(require("./commands/
|
|
14
|
-
const addScrollViewDefinition_1 = __importDefault(require("./commands/
|
|
15
|
-
const authDefinition_1 = __importDefault(require("./commands/
|
|
16
|
-
const customHelp_1 = __importDefault(require("./commands/
|
|
17
|
-
const translation_1 = __importDefault(require("./translation/translation"));
|
|
18
|
-
const createAppDefinition_1 = __importDefault(require("./commands/
|
|
19
|
-
const completionDefinition_1 = __importDefault(require("./commands/
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const addDeviceDefinition_1 = __importDefault(require("./commands/addDevice/addDeviceDefinition"));
|
|
11
|
+
const addMenuDefinition_1 = __importDefault(require("./commands/addComponent/addMenu/addMenuDefinition"));
|
|
12
|
+
const addRailDefinition_1 = __importDefault(require("./commands/addComponent/addRail/addRailDefinition"));
|
|
13
|
+
const addScreenDefinition_1 = __importDefault(require("./commands/addComponent/addScreen/addScreenDefinition"));
|
|
14
|
+
const addScrollViewDefinition_1 = __importDefault(require("./commands/addComponent/addScrollView/addScrollViewDefinition"));
|
|
15
|
+
const authDefinition_1 = __importDefault(require("./commands/authentication/authDefinition"));
|
|
16
|
+
const customHelp_1 = __importDefault(require("./commands/commandHelp/customHelp"));
|
|
17
|
+
const translation_1 = __importDefault(require("./common/translation/translation"));
|
|
18
|
+
const createAppDefinition_1 = __importDefault(require("./commands/createApp/createAppDefinition"));
|
|
19
|
+
const completionDefinition_1 = __importDefault(require("./commands/completion/completionDefinition"));
|
|
20
20
|
const makeProgram = () => {
|
|
21
|
-
const filePath =
|
|
22
|
-
const packageJson = JSON.parse(
|
|
21
|
+
const filePath = node_path_1.default.join(__dirname, "..", "package.json");
|
|
22
|
+
const packageJson = JSON.parse(node_fs_1.default.readFileSync(filePath, { encoding: "utf-8" }));
|
|
23
23
|
const program = new commander_1.Command(packageJson.name);
|
|
24
24
|
program
|
|
25
25
|
.usage(`${translation_1.default["program.usage"]}`)
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wiztivi/dana-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Dana create app CLI",
|
|
5
|
-
"
|
|
5
|
+
"exports": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"dana": "bin/dana.js"
|
|
8
8
|
},
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"command-exists": "1.2.9",
|
|
26
26
|
"commander": "11.1.x",
|
|
27
27
|
"express": "^5.1.0",
|
|
28
|
-
"g": "2.0.x",
|
|
29
28
|
"get-port": "^7.1.0",
|
|
30
29
|
"grunt-cli": "1.4.x",
|
|
31
30
|
"handlebars": "^4.7.8",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
interface SelectionItem {
|
|
2
|
-
value: string;
|
|
3
|
-
label: string;
|
|
4
|
-
}
|
|
5
|
-
export type SelectionArray = SelectionItem[];
|
|
6
|
-
export type ConfigOptions = {
|
|
7
|
-
cyclic?: boolean;
|
|
8
|
-
itemMargin?: number;
|
|
9
|
-
custom?: boolean;
|
|
10
|
-
} & Record<string, string>;
|
|
11
|
-
interface OptionItem {
|
|
12
|
-
label: string;
|
|
13
|
-
value: string;
|
|
14
|
-
command: string;
|
|
15
|
-
}
|
|
16
|
-
export type OptionList = OptionItem[];
|
|
17
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/commands/{commandDefinitions → addComponent/addScreen}/addScreenDefinition.d.ts
RENAMED
|
File without changes
|
/package/dist/commands/{add-scrollView.d.ts → addComponent/addScrollView/add-scrollView.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|