@wiztivi/dana-cli 0.0.14 → 0.0.15
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,4 +1,4 @@
|
|
|
1
|
-
import { Config } from "
|
|
1
|
+
import { Config } from "@/common/types/helperTypes.js";
|
|
2
2
|
interface TemplateFile {
|
|
3
3
|
fromPath: string;
|
|
4
4
|
config: Record<string, string>;
|
|
@@ -12,6 +12,15 @@ declare class UpdateFileHelper {
|
|
|
12
12
|
static readonly updateAppConfigFile: ({ directory }: {
|
|
13
13
|
directory: string;
|
|
14
14
|
}) => Promise<string>;
|
|
15
|
+
static readonly addModuleToAppConfig: ({ directory }: {
|
|
16
|
+
directory: string;
|
|
17
|
+
}, { modules, shouldAddIconFont }: {
|
|
18
|
+
modules: string[];
|
|
19
|
+
shouldAddIconFont: boolean;
|
|
20
|
+
}) => Promise<string>;
|
|
21
|
+
static readonly updateAppTheme: ({ directory }: {
|
|
22
|
+
directory: string;
|
|
23
|
+
}, update: string) => Promise<string>;
|
|
15
24
|
/**
|
|
16
25
|
* Update .npmrc with proper registry key
|
|
17
26
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ANDROIDTV, TITANOS, TIZEN, TVOS, VIDAA, WEBOS } from "
|
|
2
|
-
import { AndroidConfig, AndroidDevice, TizenConf, WebosConf,
|
|
1
|
+
import { ANDROIDTV, TITANOS, TIZEN, TVOS, VIDAA, WEBOS } from "@/common/const/deviceConst.js";
|
|
2
|
+
import { AndroidConfig, AndroidDevice, TizenConf, WebosConf, TvosConf, VidaaConf, TitanosConf } from "@/commands/addDevice/deviceConfig/configTypes.js";
|
|
3
3
|
interface Task {
|
|
4
4
|
title: string;
|
|
5
5
|
task: () => Promise<string>;
|
|
@@ -21,7 +21,7 @@ interface Config {
|
|
|
21
21
|
[TITANOS]?: TitanosConf;
|
|
22
22
|
}
|
|
23
23
|
interface DeviceConf {
|
|
24
|
-
device?:
|
|
24
|
+
device?: AndroidDevice;
|
|
25
25
|
renderers?: string[];
|
|
26
26
|
}
|
|
27
27
|
type JsonType = Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wiztivi/dana-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Dana create app CLI",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"exports": "./dist/
|
|
6
|
+
"exports": "./dist/bundle.min.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"dana": "bin/dana.js"
|
|
9
9
|
},
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"lint": "eslint src tests",
|
|
15
15
|
"test": "vitest",
|
|
16
16
|
"test:coverage": "vitest run --coverage",
|
|
17
|
-
"build": "npm run _clean:dist &&
|
|
18
|
-
"build:watch": "npm run _clean:dist &&
|
|
17
|
+
"build": "npm run _clean:dist && npm run _rollup && npm run _add_files:dist",
|
|
18
|
+
"build:watch": "npm run _clean:dist && rollup -c --watch",
|
|
19
19
|
"ci": "npm run build && npm run lint && npm run test:coverage",
|
|
20
20
|
"_add_files:dist": "cp ../../README.md .",
|
|
21
|
-
"_clean:dist": "rimraf ./dist tsconfig.tsbuildinfo"
|
|
21
|
+
"_clean:dist": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
22
|
+
"_rollup": "rollup -c"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist",
|
|
@@ -26,25 +27,35 @@
|
|
|
26
27
|
"README.md"
|
|
27
28
|
],
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@aws-sdk/client-codeartifact": "3.
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
30
|
+
"@aws-sdk/client-codeartifact": "3.999.0",
|
|
31
|
+
"@babel/generator": "7.29.1",
|
|
32
|
+
"@babel/parser": "7.29.0",
|
|
33
|
+
"@babel/template": "7.28.6",
|
|
34
|
+
"@babel/traverse": "7.29.0",
|
|
35
|
+
"@babel/types": "7.29.0",
|
|
36
|
+
"@clack/prompts": "1.0.1",
|
|
37
|
+
"@wiztivi/dana-templates": "^0.0.15",
|
|
32
38
|
"child_process": "1.0.x",
|
|
33
39
|
"command-exists": "1.2.9",
|
|
34
40
|
"commander": "14.0.x",
|
|
35
|
-
"express": "5.1
|
|
41
|
+
"express": "5.2.1",
|
|
42
|
+
"find-up": "8.0.0",
|
|
36
43
|
"get-port": "7.1.0",
|
|
37
44
|
"grunt-cli": "1.5.x",
|
|
38
45
|
"handlebars": "4.7.8",
|
|
39
|
-
"jsonwebtoken": "9.0.
|
|
46
|
+
"jsonwebtoken": "9.0.3",
|
|
40
47
|
"open": "11.0.0",
|
|
41
48
|
"picocolors": "1.1.x",
|
|
42
|
-
"
|
|
43
|
-
"semver": "7.7.3",
|
|
49
|
+
"semver": "7.7.4",
|
|
44
50
|
"semver-ts": "1.0.3"
|
|
45
51
|
},
|
|
46
52
|
"devDependencies": {
|
|
47
|
-
"@
|
|
53
|
+
"@rollup/plugin-commonjs": "29.0.0",
|
|
54
|
+
"@rollup/plugin-json": "6.1.0",
|
|
55
|
+
"@rollup/plugin-node-resolve": "16.0.3",
|
|
56
|
+
"@rollup/plugin-terser": "0.4.4",
|
|
57
|
+
"@rollup/plugin-typescript": "12.3.0",
|
|
58
|
+
"@types/express": "5.0.6",
|
|
48
59
|
"@types/jsonwebtoken": "9.0.10"
|
|
49
60
|
}
|
|
50
61
|
}
|
|
@@ -1,45 +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 { BUTTON_ITEM_VIEW } from "../const/componentConst.js";
|
|
13
|
-
import createComponent from "../createComponent.js";
|
|
14
|
-
import process from "node:process";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import { cpSync } from "node:fs";
|
|
17
|
-
import ComponentConfig from "../config/ComponentConfig.js";
|
|
18
|
-
import { MENU_DEFAULT_CONFIG } from "../const/defaultConfig.js";
|
|
19
|
-
import ComponentHelper from "../helper/ComponentHelper.js";
|
|
20
|
-
const addMenu = async (name, options) => {
|
|
21
|
-
const data = { ...options };
|
|
22
|
-
if (name) {
|
|
23
|
-
data.name = name;
|
|
24
|
-
}
|
|
25
|
-
const menuConfig = {
|
|
26
|
-
...data,
|
|
27
|
-
...(await ComponentConfig.menuConfig(data)),
|
|
28
|
-
};
|
|
29
|
-
const componentList = [menuConfig];
|
|
30
|
-
if (!data.custom) {
|
|
31
|
-
componentList.push({ type: BUTTON_ITEM_VIEW, name: data.itemView ?? MENU_DEFAULT_CONFIG.itemView });
|
|
32
|
-
}
|
|
33
|
-
createComponent(componentList);
|
|
34
|
-
if (!data.custom) {
|
|
35
|
-
const currentDirectory = process.cwd();
|
|
36
|
-
const modulePath = ComponentHelper.getTemplatePath();
|
|
37
|
-
const mockPath = path.join(path.dirname(modulePath), "mocks", "menuMock.json");
|
|
38
|
-
const iconPath = path.join(path.dirname(modulePath), "icons");
|
|
39
|
-
const mockFinalPath = path.resolve(currentDirectory, "menuMock.json");
|
|
40
|
-
const iconFinalPath = path.resolve(currentDirectory, "./images/icons");
|
|
41
|
-
cpSync(mockPath, mockFinalPath);
|
|
42
|
-
cpSync(iconPath, iconFinalPath, { recursive: true });
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
export default addMenu;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import addMenu from "./add-menu.js";
|
|
3
|
-
import translation from "../../../common/translation/translation.js";
|
|
4
|
-
const addMenuDefinition = () => {
|
|
5
|
-
const command = new Command("add-menu");
|
|
6
|
-
command
|
|
7
|
-
.description(translation["command.menu.description"])
|
|
8
|
-
.argument("[name]", translation["command.component.name"])
|
|
9
|
-
.option("--cm, --custom", translation["command.component.customization"])
|
|
10
|
-
.option("-i, --itemView <itemView>", translation["command.menu.option.itemView"])
|
|
11
|
-
.option("-m, --itemMargin <itemMargin>", translation["command.menu.option.itemMargin"])
|
|
12
|
-
.option("-d, --direction <direction>", translation["command.rail.option.direction"])
|
|
13
|
-
.action(addMenu);
|
|
14
|
-
return command;
|
|
15
|
-
};
|
|
16
|
-
export default addMenuDefinition;
|
|
@@ -1,42 +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 { TILE_VIEW } from "../const/componentConst.js";
|
|
13
|
-
import createComponent from "../createComponent.js";
|
|
14
|
-
import process from "node:process";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import { cpSync } from "node:fs";
|
|
17
|
-
import ComponentConfig from "../config/ComponentConfig.js";
|
|
18
|
-
import { RAIL_DEFAULT_CONFIG } from "../const/defaultConfig.js";
|
|
19
|
-
import ComponentHelper from "../helper/ComponentHelper.js";
|
|
20
|
-
const addRail = async (name, options) => {
|
|
21
|
-
const data = { ...options };
|
|
22
|
-
if (name) {
|
|
23
|
-
data.name = name;
|
|
24
|
-
}
|
|
25
|
-
const railConfig = {
|
|
26
|
-
...data,
|
|
27
|
-
...(await ComponentConfig.railConfig(data)),
|
|
28
|
-
};
|
|
29
|
-
const componentList = [railConfig];
|
|
30
|
-
if (!data.custom) {
|
|
31
|
-
componentList.push({ type: TILE_VIEW, name: data.itemView ?? RAIL_DEFAULT_CONFIG.itemView });
|
|
32
|
-
}
|
|
33
|
-
createComponent(componentList);
|
|
34
|
-
if (!data.custom) {
|
|
35
|
-
const currentDirectory = process.cwd();
|
|
36
|
-
const modulePath = ComponentHelper.getTemplatePath();
|
|
37
|
-
const mockPath = path.join(path.dirname(modulePath), "mocks", "railMock.json");
|
|
38
|
-
const finalPath = path.resolve(currentDirectory, "railMock.json");
|
|
39
|
-
cpSync(mockPath, finalPath);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
export default addRail;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import addRail from "./add-rail.js";
|
|
3
|
-
import { NAVIGATION_TYPES, DIRECTION_TYPES } from "../const/navigationConst.js";
|
|
4
|
-
import translation from "../../../common/translation/translation.js";
|
|
5
|
-
import { optionsListString } from "../../../common/helpers/stringHelper.js";
|
|
6
|
-
const addRailDefinition = () => {
|
|
7
|
-
const command = new Command("add-rail");
|
|
8
|
-
command
|
|
9
|
-
.description(translation["command.rail.description"])
|
|
10
|
-
.argument("[name]", translation["command.component.name"])
|
|
11
|
-
.option("--cm, --custom", translation["command.component.customization"])
|
|
12
|
-
.option("-n, --navigation <navigation>", translation["command.rail.option.navigation"])
|
|
13
|
-
.option("-d, --direction <direction>", translation["command.rail.option.direction"])
|
|
14
|
-
.option("-c, --cyclic", translation["command.rail.option.cyclic"])
|
|
15
|
-
.option("-i, --itemView <itemView>", translation["command.menu.option.itemView"])
|
|
16
|
-
.addHelpText("after", `
|
|
17
|
-
${translation["help.option.title"]}
|
|
18
|
-
-navigation: ${optionsListString(NAVIGATION_TYPES)}
|
|
19
|
-
-direction: ${optionsListString(DIRECTION_TYPES)}
|
|
20
|
-
|
|
21
|
-
More about rail feature, ${translation["help.option.check"]} https://doc.dana-framework.com/docs/vendorcomponents/recycling-listview
|
|
22
|
-
`)
|
|
23
|
-
.action(addRail);
|
|
24
|
-
return command;
|
|
25
|
-
};
|
|
26
|
-
export default addRailDefinition;
|
|
@@ -1,33 +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 { SCREEN, VOD_SCREEN } from "../const/componentConst.js";
|
|
13
|
-
import createComponent from "../createComponent.js";
|
|
14
|
-
import addMenu from "../addMenu/add-menu.js";
|
|
15
|
-
import addScrollView from "../addScrollView/add-scrollView.js";
|
|
16
|
-
import * as prompts from "@clack/prompts";
|
|
17
|
-
const addScreen = async (name, options) => {
|
|
18
|
-
try {
|
|
19
|
-
const data = {
|
|
20
|
-
name: name ?? "Mock",
|
|
21
|
-
type: options?.screenType ?? SCREEN,
|
|
22
|
-
};
|
|
23
|
-
if (options?.screenType === VOD_SCREEN) {
|
|
24
|
-
await addMenu(VOD_SCREEN, {});
|
|
25
|
-
await addScrollView(VOD_SCREEN, {});
|
|
26
|
-
}
|
|
27
|
-
createComponent([data]);
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
prompts.log.info(`Error creating screen: ${e.message}`);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export default addScreen;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import translation from "../../../common/translation/translation.js";
|
|
3
|
-
import addScreen from "./add-screen.js";
|
|
4
|
-
const addScreenDefinition = () => {
|
|
5
|
-
const command = new Command("add-screen");
|
|
6
|
-
command
|
|
7
|
-
.description(translation["command.screen.description"])
|
|
8
|
-
.argument("[name]", translation["command.component.name"])
|
|
9
|
-
.option("-s, --screenType [screenType]", translation["command.screen.option.type"])
|
|
10
|
-
.action(addScreen);
|
|
11
|
-
return command;
|
|
12
|
-
};
|
|
13
|
-
export default addScreenDefinition;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { SCROLL_ITEM, TILE_VIEW } from "../const/componentConst.js";
|
|
2
|
-
import createComponent from "../createComponent.js";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { cpSync } from "node:fs";
|
|
6
|
-
import { SCROLLVIEW_DEFAULT_CONFIG } from "../const/defaultConfig.js";
|
|
7
|
-
import ComponentConfig from "../config/ComponentConfig.js";
|
|
8
|
-
import ComponentHelper from "../helper/ComponentHelper.js";
|
|
9
|
-
const addScrollView = async (name, options) => {
|
|
10
|
-
const data = { ...options };
|
|
11
|
-
if (name) {
|
|
12
|
-
data.name = name;
|
|
13
|
-
}
|
|
14
|
-
const scrollViewConfig = {
|
|
15
|
-
...data,
|
|
16
|
-
...(await ComponentConfig.scrollViewConfig(data)),
|
|
17
|
-
};
|
|
18
|
-
const componentList = [scrollViewConfig];
|
|
19
|
-
if (!data.custom) {
|
|
20
|
-
componentList.push({ type: SCROLL_ITEM, name: data.itemView ?? SCROLLVIEW_DEFAULT_CONFIG.itemView }, { type: TILE_VIEW, name: "mockTile" });
|
|
21
|
-
}
|
|
22
|
-
createComponent(componentList);
|
|
23
|
-
if (!data.custom) {
|
|
24
|
-
const currentDirectory = process.cwd();
|
|
25
|
-
const modulePath = ComponentHelper.getTemplatePath();
|
|
26
|
-
const mockPath = path.join(path.dirname(modulePath), "mocks", "scrollViewMock.json");
|
|
27
|
-
const finalPath = path.resolve(currentDirectory, "scrollViewMock.json");
|
|
28
|
-
cpSync(mockPath, finalPath);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
export default addScrollView;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import addScrollView from "./add-scrollView.js";
|
|
3
|
-
import translation from "../../../common/translation/translation.js";
|
|
4
|
-
const addScrollViewDefinition = () => {
|
|
5
|
-
return new Command("add-scrollView")
|
|
6
|
-
.description(translation["command.scrollView.description"])
|
|
7
|
-
.argument("[name]", translation["command.component.name"])
|
|
8
|
-
.option("--cm, --custom", translation["command.component.customization"])
|
|
9
|
-
.option("-i, --itemView <itemView>", translation["command.menu.option.itemView"])
|
|
10
|
-
.option("-m, --itemMargin <itemMargin>", translation["command.menu.option.itemMargin"])
|
|
11
|
-
.action(addScrollView);
|
|
12
|
-
};
|
|
13
|
-
export default addScrollViewDefinition;
|
|
@@ -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 * as prompts from "@clack/prompts";
|
|
13
|
-
import ComponentHelper from "../helper/ComponentHelper.js";
|
|
14
|
-
import { DIRECTION_TYPES, NAVIGATION_TYPES } from "../const/navigationConst.js";
|
|
15
|
-
import { CANCEL } from "../../../common/const/exitCodeConst.js";
|
|
16
|
-
import { validInputLength, validNumber } from "../../../common/helpers/InputValidator.js";
|
|
17
|
-
import { RAIL_DEFAULT_CONFIG, MENU_DEFAULT_CONFIG, SCROLLVIEW_DEFAULT_CONFIG } from "../const/defaultConfig.js";
|
|
18
|
-
import { capitalizeFirstLetter } from "../../../common/helpers/stringHelper.js";
|
|
19
|
-
const ComponentConfig = class {
|
|
20
|
-
/**
|
|
21
|
-
* Get component or element name from user
|
|
22
|
-
*/
|
|
23
|
-
static askName = async (componentType, name) => {
|
|
24
|
-
if (!name) {
|
|
25
|
-
const errorMessage = `${componentType} name is mandatory !`;
|
|
26
|
-
name = (await prompts.text({
|
|
27
|
-
message: `${componentType} name`,
|
|
28
|
-
placeholder: "Placeholder Name",
|
|
29
|
-
validate: (value) => validInputLength(value, errorMessage),
|
|
30
|
-
}));
|
|
31
|
-
ComponentHelper.handleCancellation(name);
|
|
32
|
-
}
|
|
33
|
-
return name.trim();
|
|
34
|
-
};
|
|
35
|
-
static askNumber = async (valueType, numberValue) => {
|
|
36
|
-
const errorMessage = `${valueType} should be a number`;
|
|
37
|
-
const basicMessage = `Enter a value for ${valueType}`;
|
|
38
|
-
const message = numberValue && Number.isNaN(numberValue) ? `${numberValue} is not a number. ${basicMessage}` : basicMessage;
|
|
39
|
-
if (!numberValue || Number.isNaN(numberValue)) {
|
|
40
|
-
const numberValue = (await prompts.text({
|
|
41
|
-
message,
|
|
42
|
-
placeholder: "00",
|
|
43
|
-
validate: (value) => validNumber(value, errorMessage),
|
|
44
|
-
}));
|
|
45
|
-
ComponentHelper.handleCancellation(numberValue);
|
|
46
|
-
return +numberValue;
|
|
47
|
-
}
|
|
48
|
-
return numberValue;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Generic function to get option value from command line or user input
|
|
52
|
-
* @param allData
|
|
53
|
-
* @param allData.componentOption - option from command line
|
|
54
|
-
* @param allData.optionList - list of all possible values for the option
|
|
55
|
-
* @param allData.optionType - option type to be used in all prompt messages
|
|
56
|
-
*/
|
|
57
|
-
static askComponentOption = async (dataOption) => {
|
|
58
|
-
const { componentOption, optionList, optionType } = dataOption;
|
|
59
|
-
let finalOption = ComponentHelper.checkOption(componentOption, optionList, optionType);
|
|
60
|
-
if (!finalOption) {
|
|
61
|
-
const selectionMessage = `${capitalizeFirstLetter(optionType)} option`;
|
|
62
|
-
finalOption = await ComponentHelper.selectionFactory(optionType, optionList, selectionMessage);
|
|
63
|
-
}
|
|
64
|
-
return finalOption;
|
|
65
|
-
};
|
|
66
|
-
static askCyclic = async (data) => {
|
|
67
|
-
if (!data.cyclic) {
|
|
68
|
-
const cyclic = (await prompts.confirm({
|
|
69
|
-
message: "Cyclic list ?",
|
|
70
|
-
}));
|
|
71
|
-
ComponentHelper.handleCancellation(cyclic);
|
|
72
|
-
return cyclic;
|
|
73
|
-
}
|
|
74
|
-
return data.cyclic;
|
|
75
|
-
};
|
|
76
|
-
static handlePromptCancel = () => {
|
|
77
|
-
prompts.cancel("Operation cancelled.");
|
|
78
|
-
process.exit(CANCEL);
|
|
79
|
-
};
|
|
80
|
-
static getDefaultConfig = (data, defaultConfig) => {
|
|
81
|
-
return { ...defaultConfig, ...data, addMock: !data.custom };
|
|
82
|
-
};
|
|
83
|
-
static railConfig = async (data) => {
|
|
84
|
-
const config = ComponentConfig.getDefaultConfig(data, RAIL_DEFAULT_CONFIG);
|
|
85
|
-
if (data.custom) {
|
|
86
|
-
const customConfig = await prompts.group({
|
|
87
|
-
name: async () => await this.askName("rail", data.name),
|
|
88
|
-
navigation: async () => await this.askComponentOption({
|
|
89
|
-
componentOption: data.navigation,
|
|
90
|
-
optionList: NAVIGATION_TYPES,
|
|
91
|
-
optionType: "navigation",
|
|
92
|
-
}),
|
|
93
|
-
direction: async () => await this.askComponentOption({
|
|
94
|
-
componentOption: data.direction,
|
|
95
|
-
optionList: DIRECTION_TYPES,
|
|
96
|
-
optionType: "direction",
|
|
97
|
-
}),
|
|
98
|
-
isCyclic: async () => await this.askCyclic(data),
|
|
99
|
-
itemView: async () => await this.askName("itemView", data.itemView),
|
|
100
|
-
}, { onCancel: () => ComponentConfig.handlePromptCancel() });
|
|
101
|
-
return { ...config, ...customConfig };
|
|
102
|
-
}
|
|
103
|
-
return config;
|
|
104
|
-
};
|
|
105
|
-
static menuConfig = async (data) => {
|
|
106
|
-
const config = ComponentConfig.getDefaultConfig(data, MENU_DEFAULT_CONFIG);
|
|
107
|
-
if (data.custom) {
|
|
108
|
-
const customConfig = await prompts.group({
|
|
109
|
-
name: async () => await this.askName("menu", data.name),
|
|
110
|
-
itemView: async () => await this.askName("itemView", data.itemView),
|
|
111
|
-
itemMargin: async () => await this.askNumber("item margin", data.itemMargin),
|
|
112
|
-
direction: async () => await this.askComponentOption({
|
|
113
|
-
componentOption: data.direction,
|
|
114
|
-
optionList: DIRECTION_TYPES,
|
|
115
|
-
optionType: "direction",
|
|
116
|
-
}),
|
|
117
|
-
}, { onCancel: () => ComponentConfig.handlePromptCancel() });
|
|
118
|
-
return { ...config, ...customConfig };
|
|
119
|
-
}
|
|
120
|
-
return config;
|
|
121
|
-
};
|
|
122
|
-
static scrollViewConfig = async (data) => {
|
|
123
|
-
const config = ComponentConfig.getDefaultConfig(data, SCROLLVIEW_DEFAULT_CONFIG);
|
|
124
|
-
if (data.custom) {
|
|
125
|
-
const customConfig = await prompts.group({
|
|
126
|
-
name: async () => await this.askName("scrollView", data.name),
|
|
127
|
-
itemView: async () => await this.askName("itemView", data.itemView),
|
|
128
|
-
itemMargin: async () => await this.askNumber("item margin", data.itemMargin),
|
|
129
|
-
}, { onCancel: () => ComponentConfig.handlePromptCancel() });
|
|
130
|
-
return { ...config, ...customConfig };
|
|
131
|
-
}
|
|
132
|
-
return config;
|
|
133
|
-
};
|
|
134
|
-
static screenConfig = async (data) => {
|
|
135
|
-
return {
|
|
136
|
-
name: data.name ?? (await this.askName("screen")),
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
export default ComponentConfig;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +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
|
-
export const MENU = "wtvMenuListView";
|
|
13
|
-
export const RAIL = "wtvRailListView";
|
|
14
|
-
export const TILE_VIEW = "tileView";
|
|
15
|
-
export const SCROLL_VIEW = "scrollView";
|
|
16
|
-
export const SCROLL_ITEM = "scrollItemView";
|
|
17
|
-
export const BUTTON_ITEM_VIEW = "ButtonItemView";
|
|
18
|
-
export const SCREEN = "screen";
|
|
19
|
-
export const VOD_SCREEN = "vod";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MENU, SCROLL_VIEW, RAIL } from "./componentConst.js";
|
|
2
|
-
export const RAIL_DEFAULT_CONFIG = {
|
|
3
|
-
navigation: "FixedNavigationType",
|
|
4
|
-
isCyclic: false,
|
|
5
|
-
direction: "horizontal",
|
|
6
|
-
name: "mockRail",
|
|
7
|
-
itemView: "mockTile",
|
|
8
|
-
type: RAIL,
|
|
9
|
-
addMock: true,
|
|
10
|
-
};
|
|
11
|
-
export const MENU_DEFAULT_CONFIG = {
|
|
12
|
-
name: "mockMenu",
|
|
13
|
-
itemMargin: 20,
|
|
14
|
-
itemView: "ButtonItem",
|
|
15
|
-
direction: "horizontal",
|
|
16
|
-
addMock: true,
|
|
17
|
-
type: MENU,
|
|
18
|
-
};
|
|
19
|
-
export const SCROLLVIEW_DEFAULT_CONFIG = {
|
|
20
|
-
name: "mock",
|
|
21
|
-
itemMargin: 550,
|
|
22
|
-
itemView: "Rail",
|
|
23
|
-
type: SCROLL_VIEW,
|
|
24
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import colors from "picocolors";
|
|
2
|
-
export const NAVIGATION_TYPES = [
|
|
3
|
-
{
|
|
4
|
-
value: "MFixedNavigationType",
|
|
5
|
-
label: colors.bold("Fixed. ") + "Focus is fixed on the left side of the list.",
|
|
6
|
-
command: "fixed",
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
value: "MLMRNavigationType",
|
|
10
|
-
label: colors.bold("Left-Middle-Right. ") +
|
|
11
|
-
"Focus starts on the left side, then moves and stays to the middle, then goes to the right side when the list ends",
|
|
12
|
-
command: "lmr",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
value: "MLRNavigationType",
|
|
16
|
-
label: colors.bold("Left-Right. ") +
|
|
17
|
-
" Focus moves in the chosen direction to the edge of the list. Then the list scrolls to show the next items.",
|
|
18
|
-
command: "lr",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
value: "MPaginateNavigationType",
|
|
22
|
-
label: colors.bold("Paginated. ") +
|
|
23
|
-
" Focus moves to the end of the visible items. Then, all items are replaced by new ones.",
|
|
24
|
-
command: "paginated",
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
export const DIRECTION_TYPES = [
|
|
28
|
-
{ value: `HORIZONTAL`, label: "HORIZONTAL", command: "h" },
|
|
29
|
-
{ value: `VERTICAL`, label: "VERTICAL", command: "v" },
|
|
30
|
-
];
|
|
@@ -1,41 +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 ComponentHelper from "./helper/ComponentHelper.js";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
import { writeFileSync } from "node:fs";
|
|
15
|
-
import { templateGenerator } from "../../common/helpers/handlebarsHelper.js";
|
|
16
|
-
import * as prompts from "@clack/prompts";
|
|
17
|
-
import { COMPONENT_ERROR } from "../../common/const/exitCodeConst.js";
|
|
18
|
-
import translation from "../../common/translation/translation.js";
|
|
19
|
-
const createSingleComponent = (data, currentDirectory, modulePath) => {
|
|
20
|
-
try {
|
|
21
|
-
const templatePath = path.join(path.dirname(modulePath), "components", `${data.type}.js.hbs`);
|
|
22
|
-
const output = templateGenerator(templatePath, data);
|
|
23
|
-
const finalPath = path.resolve(currentDirectory, ComponentHelper.normalizeFileName(data.type, data.name));
|
|
24
|
-
writeFileSync(finalPath, output, { encoding: "utf-8" });
|
|
25
|
-
prompts.log.success(`${data.name} ${translation["component.creation.success"]}`);
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
const simpleMessage = `Failed to create component ${data.name}`;
|
|
29
|
-
const message = e instanceof Error ? `${simpleMessage}: ${e.message}` : simpleMessage;
|
|
30
|
-
prompts.log.error(message);
|
|
31
|
-
process.exit(COMPONENT_ERROR);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const createComponent = (componentList) => {
|
|
35
|
-
const currentDirectory = process.cwd();
|
|
36
|
-
const modulePath = ComponentHelper.getTemplatePath();
|
|
37
|
-
for (const data of componentList) {
|
|
38
|
-
createSingleComponent(data, currentDirectory, modulePath);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
export default createComponent;
|