@nebula.js/cli-create 7.2.0 → 7.4.0

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 CHANGED
@@ -28,6 +28,8 @@ Options:
28
28
  --install Run package installation step [boolean] [default: true]
29
29
  --pkgm Package manager [string] [choices: "npm", "yarn", "pnpm"]
30
30
  --picasso Picasso template [string] [choices: "none", "minimal", "barchart"]
31
+ --typescript Generate a TypeScript visualization scaffold
32
+ [boolean] [default: false]
31
33
  --author Package author [string]
32
34
  -h, --help Show help [boolean]
33
35
  ```
@@ -65,6 +67,10 @@ options.
65
67
  - minimal: a basic setup of picasso.js is ready
66
68
  - barchart: a bar chart component created by picasso.js is ready
67
69
 
70
+ Generate a TypeScript visualization scaffold by adding `--typescript`. This
71
+ adds `tsconfig.json`, `nebula.config.js`, TypeScript build dependencies, and
72
+ TypeScript source files for the generated visualization.
73
+
68
74
  You can find the [tutorial](https://qlik.dev/extend/extend-quickstarts/first-extension) to build a basic nebula visualization using nebula.js.
69
75
 
70
76
  #### Create a mashup
@@ -103,3 +109,11 @@ Create a mashup and do not install any dependencies yet
103
109
  ```sh
104
110
  nebula create mashup table-mashup --install false
105
111
  ```
112
+
113
+ #### TypeScript scaffold
114
+
115
+ Create a nebula visualization project with a TypeScript scaffold
116
+
117
+ ```sh
118
+ nebula create sn-table --typescript
119
+ ```
package/command.js CHANGED
@@ -44,6 +44,11 @@ export default {
44
44
  type: 'string',
45
45
  description: 'Package author',
46
46
  });
47
+ yargs.option('typescript', {
48
+ type: 'boolean',
49
+ default: false,
50
+ description: 'Generate a TypeScript visualization scaffold',
51
+ });
47
52
  },
48
53
  handler(argv) {
49
54
  create(argv);
package/lib/create.js CHANGED
@@ -59,11 +59,49 @@ function copyFactory(root, destination) {
59
59
  };
60
60
  }
61
61
 
62
+ const renameJavascriptSourcesToTypescript = (target) => {
63
+ if (!fse.existsSync(target)) {
64
+ return;
65
+ }
66
+
67
+ const entries = fs.readdirSync(target, { withFileTypes: true });
68
+ entries.forEach((entry) => {
69
+ const currentPath = path.resolve(target, entry.name);
70
+ if (entry.isDirectory()) {
71
+ renameJavascriptSourcesToTypescript(currentPath);
72
+ return;
73
+ }
74
+
75
+ if (entry.isFile() && path.extname(entry.name) === '.js') {
76
+ const nextPath = currentPath.replace(/\.js$/, '.ts');
77
+ fs.renameSync(currentPath, nextPath);
78
+ }
79
+ });
80
+ };
81
+
82
+ const scaffoldTypescript = ({ destination }) => {
83
+ renameJavascriptSourcesToTypescript(path.resolve(destination, 'src'));
84
+
85
+ fs.copyFileSync(
86
+ path.resolve(moduleDir, '../templates/sn/typescript/tsconfig.json'),
87
+ path.resolve(destination, 'tsconfig.json')
88
+ );
89
+ fs.copyFileSync(
90
+ path.resolve(moduleDir, '../templates/sn/typescript/nebula.config.js'),
91
+ path.resolve(destination, 'nebula.config.js')
92
+ );
93
+ };
94
+
62
95
  const create = async (argv) => {
63
96
  const { name } = argv;
64
97
 
65
98
  const isMashup = argv._.includes('mashup');
66
99
 
100
+ if (isMashup && argv.typescript) {
101
+ console.error(chalk.red('TypeScript scaffolding is only supported for visualizations.'));
102
+ process.exit(1);
103
+ }
104
+
67
105
  const projectFolder = name;
68
106
  const packageName = name.split('/').slice(-1)[0];
69
107
 
@@ -129,6 +167,7 @@ const create = async (argv) => {
129
167
  user: options.author.name,
130
168
  email: options.author.email,
131
169
  nebulaVersion: pkg.version,
170
+ typescript: Boolean(options.typescript),
132
171
  };
133
172
 
134
173
  const traverse = (sourceFolder, targetFolder = '') => {
@@ -153,6 +192,10 @@ const create = async (argv) => {
153
192
  folders.forEach((folder) => {
154
193
  traverse(folder);
155
194
  });
195
+
196
+ if (options.typescript) {
197
+ scaffoldTypescript({ destination });
198
+ }
156
199
  };
157
200
 
158
201
  const install = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula.js/cli-create",
3
- "version": "7.2.0",
3
+ "version": "7.4.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -24,9 +24,11 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@inquirer/prompts": "8.5.2",
27
- "chalk": "4.1.2",
27
+ "chalk": "6.0.0",
28
28
  "ejs": "6.0.1",
29
- "fs-extra": "11.4.0"
29
+ "fs-extra": "11.4.0",
30
+ "picasso-plugin-q": "2.11.5",
31
+ "picasso.js": "2.11.5"
30
32
  },
31
- "gitHead": "44ddc01b77f775b3a2b028f991a6dfd349a70871"
33
+ "gitHead": "c080c816b30c0caf2647330f8f7320fc81ee1002"
32
34
  }
@@ -16,7 +16,7 @@
16
16
  "@nebula.js/stardust": "<%= nebulaVersion %>",
17
17
  "@nebula.js/sn-bar-chart": "^2.2.0",
18
18
  "@qlik/api": "2.7.0",
19
- "enigma.js": "^2.14.0",
19
+ "enigma.js": "2.14.0",
20
20
  "parcel": "2.16.4"
21
21
  }
22
22
  }
@@ -17,7 +17,7 @@ export default {
17
17
  ],
18
18
 
19
19
  webServer: {
20
- command: 'yarn start --port 8077 --open false',
20
+ command: 'pnpm start --port 8077 --open false',
21
21
  reuseExistingServer: !process.env.CI,
22
22
  port: '8077',
23
23
  },
@@ -15,7 +15,7 @@
15
15
  "main": "dist/<%= name %>.js",
16
16
  "module": "dist/<%= name %>.esm.js",
17
17
  "scripts": {
18
- "build": "nebula build",
18
+ "build": "nebula build<% if (typescript) { %> --typescript<% } %>",
19
19
  "start": "nebula serve",
20
20
  "sense": "nebula sense --meta src/meta.json",
21
21
  "test:e2e": "playwright test",
@@ -26,7 +26,10 @@
26
26
  "@nebula.js/cli-build": "<%= nebulaVersion %>",
27
27
  "@nebula.js/cli-serve": "<%= nebulaVersion %>",
28
28
  "@nebula.js/cli-sense": "<%= nebulaVersion %>",
29
- "@playwright/test": "^1.59.1"
29
+ "@playwright/test": "^1.59.1"<% if (typescript) { %>,
30
+ "@rollup/plugin-typescript": "12.3.0",
31
+ "tslib": "^2.8.1",
32
+ "typescript": ">=5.9.3 <7"<% } %>
30
33
  },
31
34
  "peerDependencies": {
32
35
  "@nebula.js/stardust": ">=7.0.0"
@@ -15,7 +15,7 @@
15
15
  "main": "dist/<%= name %>.js",
16
16
  "module": "dist/<%= name %>.esm.js",
17
17
  "scripts": {
18
- "build": "nebula build",
18
+ "build": "nebula build<% if (typescript) { %> --typescript<% } %>",
19
19
  "start": "nebula serve",
20
20
  "sense": "nebula sense",
21
21
  "test:e2e": "playwright test",
@@ -28,7 +28,10 @@
28
28
  "@nebula.js/cli-sense": "<%= nebulaVersion %>",
29
29
  "@playwright/test": "^1.28.1",
30
30
  "picasso.js": "2.1.1",
31
- "picasso-plugin-q": "2.1.1"
31
+ "picasso-plugin-q": "2.1.1"<% if (typescript) { %>,
32
+ "@rollup/plugin-typescript": "12.3.0",
33
+ "tslib": "^2.8.1",
34
+ "typescript": ">=5.9.3 <7"<% } %>
32
35
  },
33
36
  "peerDependencies": {
34
37
  "@nebula.js/stardust": ">=7.0.0"
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ build: {
3
+ typescript: true,
4
+ },
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "resolveJsonModule": true,
8
+ "skipLibCheck": true,
9
+ "strict": false
10
+ },
11
+ "include": ["src/**/*.ts"]
12
+ }