@wiztivi/dana-cli 0.0.6 → 0.0.8

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 ADDED
@@ -0,0 +1,47 @@
1
+ ![Dana Logo](tools/templates/app-template/images/dana.png)
2
+
3
+ # Dana-cli
4
+
5
+ Dana is a JavaScript framework built for TV apps.
6
+ It aims at enabling the creation of natively performant TV applications on all currently available TV platforms.
7
+ Code once, deploy across all major platforms (Samsung Tizen, LG WebOS, Android TV, AppleTV, Xbox...) using a single codebase.
8
+
9
+ This cli is a companion tool made to help you boostrap an application with Dana.
10
+
11
+ ## Requirements
12
+
13
+ To be able to use the dana-cli, you will need:
14
+
15
+ - Node > 20,
16
+ - an account on [Dana Cloud Service](https://app.public.dana-framework.com/)
17
+
18
+ ## Getting started
19
+
20
+ First you'll need to use your account to authenticate to Dana Cloud Service platform:
21
+
22
+ ```bash
23
+ npx @wiztivi/dana-cli auth login
24
+ ```
25
+
26
+ This should open a browser and ask for your account credentials.
27
+
28
+ Then you can create a simple template of your application by running the following command:
29
+
30
+ ```bash
31
+ npx @wiztivi/dana-cli create-app <project-name>
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Use the CLI to:
37
+
38
+ - create a new app project
39
+ - add device(s) easily to deploy your project on more platforms: `npx @wiztivi/dana-cli add-device`,
40
+ - add built-in components to your project: eg `npx @wiztivi/dana-cli add-menu`
41
+ - get autocompletion script for dana commands: `npx @wiztivi/dana-cli completion <shell>`
42
+
43
+ To get all available options and more information:`npx @wiztivi/dana-cli help`
44
+
45
+ ## Screenshots
46
+
47
+ ![VOD Screen 1](images/vodScreen1.png)
@@ -11,13 +11,13 @@ dana_commands=(
11
11
  'add-scrollView'
12
12
  'add-screen'
13
13
  'auth'
14
+ 'create-app'
14
15
  )
15
16
 
16
17
  # Shared subcommand declarations
17
18
  login_sub="login"
18
19
  logout_sub="logout"
19
20
  status_sub="status"
20
-
21
21
  # Shared option declarations
22
22
  direction_opts="-d --direction"
23
23
  navigation_opts="-n --navigation"
@@ -26,12 +26,13 @@ margin_opts="-m --itemMargin"
26
26
  custom_opts="-cm --custom"
27
27
  item_view_opts="-i --itemView"
28
28
  org_opts="-o --org"
29
+ device_opts="-d --device"
30
+ tutorial_opts="-t, --tutorial"
29
31
 
30
32
  # Shared option values
31
33
  direction_values="h v"
32
34
  navigation_values="fixed lmr lr paginated"
33
35
  org_values="preprod"
34
-
35
36
  # Detect shell and load appropriate completion
36
37
  if [ -n "$BASH_VERSION" ]; then
37
38
  # Bash completion
@@ -40,7 +41,6 @@ if [ -n "$BASH_VERSION" ]; then
40
41
  local cur prev opts
41
42
  cur="${COMP_WORDS[COMP_CWORD]}"
42
43
  prev="${COMP_WORDS[COMP_CWORD-1]}"
43
-
44
44
  # Complete option values
45
45
  case "$prev" in
46
46
  -d|--direction)
@@ -56,13 +56,11 @@ if [ -n "$BASH_VERSION" ]; then
56
56
  return 0
57
57
  ;;
58
58
  esac
59
-
60
59
  # If we're completing the first argument (command)
61
60
  if [[ $COMP_CWORD -eq 1 ]]; then
62
61
  COMPREPLY=($(compgen -W "${dana_commands[*]}" -- "$cur"))
63
62
  return 0
64
63
  fi
65
-
66
64
  # If we're completing options for specific commands
67
65
  local cmd="${COMP_WORDS[1]}"
68
66
  case "$cmd" in
@@ -86,14 +84,16 @@ if [ -n "$BASH_VERSION" ]; then
86
84
  fi
87
85
  COMPREPLY=($(compgen -W "$opts" -- "$cur"))
88
86
  ;;
87
+ create-app)
88
+ opts="$device_opts $tutorial_opts"
89
+ COMPREPLY=($(compgen -W "$opts" -- "$cur"))
90
+ ;;
89
91
  *)
90
92
  COMPREPLY=()
91
93
  ;;
92
94
  esac
93
95
  }
94
-
95
96
  complete -F _dana dana
96
-
97
97
  elif [ -n "$ZSH_VERSION" ]; then
98
98
  # Zsh completion
99
99
  _dana() {
@@ -104,7 +104,6 @@ elif [ -n "$ZSH_VERSION" ]; then
104
104
  compadd -a commands
105
105
  return
106
106
  fi
107
-
108
107
  # Complete option values
109
108
  local prev=${words[CURRENT-1]}
110
109
  case "$prev" in
@@ -125,7 +124,6 @@ elif [ -n "$ZSH_VERSION" ]; then
125
124
  return
126
125
  ;;
127
126
  esac
128
-
129
127
  # Complete options for commands
130
128
  local cmd=${words[2]}
131
129
  case "$cmd" in
@@ -145,6 +143,8 @@ elif [ -n "$ZSH_VERSION" ]; then
145
143
  compadd -- ${=org_opts}
146
144
  fi
147
145
  ;;
146
+ create-app)
147
+ compadd -- ${device_opts} $={tutorial_opts}
148
148
  esac
149
149
  }
150
150
 
@@ -24,6 +24,7 @@ import translation from "../../common/translation/translation.js";
24
24
  import { CredentialsHelper } from "../authentication/helper/CredentialsHelper.js";
25
25
  const addDevice = async () => {
26
26
  prompts.intro(`Add device(s) to ${path.basename(process.cwd())} !`);
27
+ const spinner = prompts.spinner();
27
28
  const data = {};
28
29
  try {
29
30
  data.directory = "./";
@@ -49,6 +50,7 @@ const addDevice = async () => {
49
50
  process.exit(DEVICE_ERROR);
50
51
  }
51
52
  try {
53
+ spinner.start(translation["task.installation.start"]);
52
54
  await CreateAppHelper.installation([
53
55
  {
54
56
  title: "Update package.json",
@@ -74,14 +76,15 @@ const addDevice = async () => {
74
76
  title: "Execute devices config",
75
77
  task: async () => UpdateFileHelper.setDevicesConfig(data),
76
78
  },
77
- ]);
79
+ ], spinner);
78
80
  }
79
81
  catch (e) {
80
- AddDeviceHelper.cleanOnError();
82
+ spinner.stop();
81
83
  const message = e instanceof Error ? e.message : e;
82
84
  prompts.outro(colors.red(`${translation["error.common.start.message"]} ${message}`));
83
85
  process.exit(DEVICE_ERROR);
84
86
  }
87
+ spinner.stop(translation["task.installation.end"]);
85
88
  prompts.outro("Everything is ready ! Don't forget to commit your change.");
86
89
  return;
87
90
  };
@@ -1,4 +1,9 @@
1
1
  import { Config } from "../types/helperTypes.js";
2
+ interface TemplateFile {
3
+ fromPath: string;
4
+ config: Record<string, string>;
5
+ toPath: string;
6
+ }
2
7
  declare class UpdateFileHelper {
3
8
  /**
4
9
  * Update app.Config files with mandatory Data
@@ -36,5 +41,6 @@ declare class UpdateFileHelper {
36
41
  directory: string;
37
42
  name: string;
38
43
  }) => Promise<string>;
44
+ static readonly getConfigFileOutput: (directory: string) => TemplateFile[];
39
45
  }
40
46
  export default UpdateFileHelper;
@@ -104,13 +104,9 @@ class UpdateFileHelper {
104
104
  config: { appName },
105
105
  toPath: path.join(directory, "tests", "unit", "app", `${appName}AppRoutes.js`),
106
106
  },
107
- {
108
- fromPath: path.join(directory, "gitignoreTemplate.hbs"),
109
- config: {},
110
- toPath: path.join(directory, `.gitignore`),
111
- },
112
107
  ];
113
- for (const file of filesToUpdate) {
108
+ const finalListToUpdate = filesToUpdate.concat(UpdateFileHelper.getConfigFileOutput(directory));
109
+ for (const file of finalListToUpdate) {
114
110
  const updatedContent = templateGenerator(file.fromPath, file.config);
115
111
  fs.writeFileSync(file.toPath, updatedContent);
116
112
  fs.unlink(file.fromPath, (err) => {
@@ -120,5 +116,17 @@ class UpdateFileHelper {
120
116
  }
121
117
  return Promise.resolve("Files templated");
122
118
  };
119
+ static getConfigFileOutput = function (directory) {
120
+ const configFiles = ["gitignoreTemplate.hbs", "editorConfigTemplate.hbs", "eslintrc.jsonTemplate.hbs"];
121
+ const filesToUpdate = [];
122
+ for (const configFile of configFiles) {
123
+ filesToUpdate.push({
124
+ fromPath: path.join(directory, configFile),
125
+ config: {},
126
+ toPath: path.join(directory, `.${configFile.replace("Template.hbs", "")}`),
127
+ });
128
+ }
129
+ return filesToUpdate;
130
+ };
123
131
  }
124
132
  export default UpdateFileHelper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wiztivi/dana-cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Dana create app CLI",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -14,17 +14,21 @@
14
14
  "lint": "eslint src tests",
15
15
  "test": "vitest",
16
16
  "test:coverage": "vitest run --coverage",
17
- "build": "rimraf ./dist tsconfig.tsbuildinfo && tsc --build && cp dana_completion.sh dist/",
18
- "ci": "npm run build && npm run lint && npm run test:coverage"
17
+ "build": "npm run _clean:dist && tsc --build && npm run _add_files:dist",
18
+ "build:watch": "npm run _clean:dist && tsc --build --watch",
19
+ "ci": "npm run build && npm run lint && npm run test:coverage",
20
+ "_add_files:dist": "cp ../../README.md .",
21
+ "_clean:dist": "rimraf ./dist tsconfig.tsbuildinfo"
19
22
  },
20
23
  "files": [
21
24
  "dist",
22
- "dana_completion.sh"
25
+ "dana_completion.sh",
26
+ "README.md"
23
27
  ],
24
28
  "dependencies": {
25
29
  "@aws-sdk/client-codeartifact": "^3.859.0",
26
30
  "@clack/prompts": "0.10.0",
27
- "@wiztivi/dana-templates": "^0.0.6",
31
+ "@wiztivi/dana-templates": "^0.0.8",
28
32
  "child_process": "1.0.x",
29
33
  "command-exists": "1.2.9",
30
34
  "commander": "11.1.x",
@@ -1,153 +0,0 @@
1
- #!/usr/bin/env sh
2
-
3
- # Unified completion script for dana CLI
4
- # Detects shell and loads appropriate completion
5
-
6
- # Shared command list
7
- dana_commands=(
8
- 'add-device'
9
- 'add-menu'
10
- 'add-rail'
11
- 'add-scrollView'
12
- 'add-screen'
13
- 'auth'
14
- )
15
-
16
- # Shared subcommand declarations
17
- login_sub="login"
18
- logout_sub="logout"
19
- status_sub="status"
20
-
21
- # Shared option declarations
22
- direction_opts="-d --direction"
23
- navigation_opts="-n --navigation"
24
- cyclic_opts="-c --cyclic"
25
- margin_opts="-m --itemMargin"
26
- custom_opts="-cm --custom"
27
- item_view_opts="-i --itemView"
28
- org_opts="-o --org"
29
-
30
- # Shared option values
31
- direction_values="h v"
32
- navigation_values="fixed lmr lr paginated"
33
- org_values="preprod"
34
-
35
- # Detect shell and load appropriate completion
36
- if [ -n "$BASH_VERSION" ]; then
37
- # Bash completion
38
- _dana()
39
- {
40
- local cur prev opts
41
- cur="${COMP_WORDS[COMP_CWORD]}"
42
- prev="${COMP_WORDS[COMP_CWORD-1]}"
43
-
44
- # Complete option values
45
- case "$prev" in
46
- -d|--direction)
47
- COMPREPLY=($(compgen -W "$direction_values" -- "$cur"))
48
- return 0
49
- ;;
50
- -n|--navigation)
51
- COMPREPLY=($(compgen -W "$navigation_values" -- "$cur"))
52
- return 0
53
- ;;
54
- -o|--org)
55
- COMPREPLY=($(compgen -W "$org_values" -- "$cur"))
56
- return 0
57
- ;;
58
- esac
59
-
60
- # If we're completing the first argument (command)
61
- if [[ $COMP_CWORD -eq 1 ]]; then
62
- COMPREPLY=($(compgen -W "${dana_commands[*]}" -- "$cur"))
63
- return 0
64
- fi
65
-
66
- # If we're completing options for specific commands
67
- local cmd="${COMP_WORDS[1]}"
68
- case "$cmd" in
69
- add-rail)
70
- opts="$navigation_opts $cyclic_opts $direction_opts $custom_opts $item_view_opts"
71
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
72
- ;;
73
- add-menu)
74
- opts="$direction_opts $margin_opts $custom_opts $item_view_opts"
75
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
76
- ;;
77
- add-scrollView)
78
- opts="$custom_opts $item_view_opts $margin_opts"
79
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
80
- ;;
81
- auth)
82
- if [[ $COMP_CWORD -eq 2 ]]; then
83
- opts="$login_sub $logout_sub $status_sub"
84
- else
85
- opts="$org_opts"
86
- fi
87
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
88
- ;;
89
- *)
90
- COMPREPLY=()
91
- ;;
92
- esac
93
- }
94
-
95
- complete -F _dana dana
96
-
97
- elif [ -n "$ZSH_VERSION" ]; then
98
- # Zsh completion
99
- _dana() {
100
- # Main commands
101
- if (( CURRENT == 2 )); then
102
- local -a commands
103
- commands=(${dana_commands[@]})
104
- compadd -a commands
105
- return
106
- fi
107
-
108
- # Complete option values
109
- local prev=${words[CURRENT-1]}
110
- case "$prev" in
111
- -d|--direction)
112
- compadd -- ${=direction_values}
113
- return
114
- ;;
115
- -n|--navigation)
116
- compadd -- ${=navigation_values}
117
- return
118
- ;;
119
- -o|--org)
120
- compadd -- ${=org_values}
121
- return
122
- ;;
123
- login|logout|status)
124
- compadd -- ${=org_opts}
125
- return
126
- ;;
127
- esac
128
-
129
- # Complete options for commands
130
- local cmd=${words[2]}
131
- case "$cmd" in
132
- add-rail)
133
- compadd -- ${=navigation_opts} ${=cyclic_opts} ${=direction_opts} ${=custom_opts} ${=item_view_opts}
134
- ;;
135
- add-menu)
136
- compadd -- ${=direction_opts} ${=margin_opts} ${=custom_opts} ${=item_view_opts}
137
- ;;
138
- add-scrollView)
139
- compadd -- ${=custom_opts} ${=item_view_opts} ${=margin_opts}
140
- ;;
141
- auth)
142
- if (( CURRENT == 3 )); then
143
- compadd -- ${=login_sub} ${=logout_sub} ${=status_sub}
144
- else
145
- compadd -- ${=org_opts}
146
- fi
147
- ;;
148
- esac
149
- }
150
-
151
- # Register the completion
152
- compdef _dana dana
153
- fi