@twick/create 0.14.0 → 0.14.2

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.
Files changed (3) hide show
  1. package/LICENSE +21 -21
  2. package/index.js +260 -260
  3. package/package.json +9 -9
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 motion-canvas
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 motion-canvas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/index.js CHANGED
@@ -1,260 +1,260 @@
1
- #!/usr/bin/env node
2
- //@ts-check
3
- import {EventName, sendEvent} from '@twick/telemetry';
4
- import fs from 'fs';
5
- import kleur from 'kleur';
6
- import minimist from 'minimist';
7
- import {fileURLToPath} from 'node:url';
8
- import path from 'path';
9
- import prompts from 'prompts';
10
-
11
- const templates = [
12
- {
13
- value: 'default',
14
- title: 'Minimal, standalone Twick project',
15
- description: 'A minimal example to get started with Twick.',
16
- recommended: true,
17
- startcommands: 'default',
18
- },
19
- {
20
- value: 'saas-template',
21
- title: 'Twick with Next.js',
22
- description: 'A minimal web app built with Twick and Next.js.',
23
- recommended: true,
24
- startcommands: 'readme',
25
- },
26
- {
27
- value: 'avatar-with-background',
28
- title: 'Avatar with Background',
29
- description: 'Create an avatar with a custom background.',
30
- startcommands: 'default',
31
- },
32
- {
33
- value: 'github-stars-celebration',
34
- title: 'GitHub Stars Celebration',
35
- description: 'Animate a celebration of GitHub repository stars.',
36
- startcommands: 'default',
37
- },
38
- {
39
- value: 'marketing-templates',
40
- title: 'Marketing Templates',
41
- description: 'A collection of templates for marketing videos.',
42
- startcommands: 'readme',
43
- },
44
- {
45
- value: 'minimal-drag-drop',
46
- title: 'Drag and Drop Example',
47
- description:
48
- 'A minimal example of an editor with drag-and-drop editing functionality.',
49
- startcommands: 'readme',
50
- },
51
- {
52
- value: 'parallelized-aws-lambda',
53
- title: 'Parallelized AWS Lambda',
54
- description: 'Example of parallelized rendering using AWS Lambda.',
55
- startcommands: 'readme',
56
- },
57
- {
58
- value: 'rive-explanation-video',
59
- title: 'Rive Explanation Video',
60
- description: 'Create a code explanation video along with Rive animations.',
61
- startcommands: 'default',
62
- },
63
- {
64
- value: 'stitching-videos',
65
- title: 'Stitching Videos',
66
- description: 'Example of how to concatenate multiple videos together.',
67
- startcommands: 'default',
68
- },
69
- {
70
- value: 'three-js-example',
71
- title: 'Three.js Example',
72
- description: 'Integrate Three.js with Twick for 3D animations.',
73
- startcommands: 'default',
74
- },
75
- {
76
- value: 'youtube-shorts',
77
- title: 'YouTube Shorts',
78
- description: 'Template for creating YouTube Shorts videos.',
79
- startcommands: 'default',
80
- },
81
- ];
82
-
83
- async function run() {
84
- const options = minimist(process.argv.slice(2));
85
-
86
- const templateFlag = Object.keys(options).find(key =>
87
- templates.some(template => template.value === key),
88
- );
89
-
90
- const pathResponse = await prompts([
91
- // Prompt for project name
92
- {
93
- type: 'text',
94
- name: 'name',
95
- message: 'Project name',
96
- initial: 'my-twick-project',
97
- validate: value =>
98
- isValidPackageName(value)
99
- ? true
100
- : 'Project name must be a valid npm package name.',
101
- },
102
- // Prompt for project path
103
- {
104
- type: 'text',
105
- name: 'path',
106
- message: 'Project path',
107
-
108
- initial: value => {
109
- return path.normalize(value.replace('@', ''));
110
- },
111
-
112
- validate: value => {
113
- let dir = path.normalize(value.trim());
114
- if (!fs.existsSync(dir)) {
115
- return true;
116
- }
117
- if (!fs.lstatSync(dir).isDirectory()) {
118
- return `Project path "${dir}" must be a valid directory.`;
119
- }
120
- if (fs.readdirSync(dir).length > 0) {
121
- return dir === '.'
122
- ? 'Current directory must be empty.'
123
- : `Target directory "${dir}" must be empty.`;
124
- }
125
- return true;
126
- },
127
- format: value => path.resolve(value),
128
- },
129
- ]);
130
-
131
- console.log(); // linebreak for better readability
132
-
133
- let templateResponse;
134
- if (templateFlag) {
135
- templateResponse = {starter: templateFlag};
136
- } else {
137
- // Prompt for which example to scaffold
138
- templateResponse = await prompts([
139
- {
140
- type: 'select',
141
- name: 'starter',
142
- message: 'Choose a starter template',
143
- choices: templates.map(template => ({
144
- title: template.recommended
145
- ? template.title + kleur.bold(' (Recommended)')
146
- : template.title,
147
- value: template.value,
148
- description: template.description,
149
- })),
150
- },
151
- ]);
152
- }
153
-
154
- const response = {...pathResponse, ...templateResponse};
155
-
156
- // Abort if the user didn't provide a project name
157
- if (!response.path) {
158
- console.log(kleur.red('× Scaffolding aborted by the user.\n'));
159
- return;
160
- }
161
-
162
- console.log('Scaffolding, this can take a few seconds...');
163
-
164
- // Clone files
165
- const templateDir = path.resolve(
166
- fileURLToPath(import.meta.url),
167
- '..',
168
- `examples/${response.starter}`,
169
- );
170
- copyDirectory(templateDir, response.path);
171
-
172
- sendEvent(EventName.CreateCommand, {
173
- name: response.name,
174
- starter: response.starter,
175
- });
176
-
177
- // Read package.json and modify name
178
- try {
179
- const manifest = JSON.parse(
180
- fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8'),
181
- );
182
- manifest.name = response.name;
183
- fs.writeFileSync(
184
- path.join(response.path, 'package.json'),
185
- JSON.stringify(manifest, undefined, 2),
186
- );
187
- } catch (e) {
188
- // Example doesn't have a package.json file
189
- }
190
-
191
- // Tell user that the process is complete
192
- const manager = getPackageManager();
193
- console.log(
194
- kleur.green(
195
- '\n√ Scaffolding complete. Run the following commands to get started:',
196
- ),
197
- );
198
- if (response.path !== process.cwd()) {
199
- console.log(
200
- ` ${kleur.bold('cd')} ${path.relative(process.cwd(), response.path)}`,
201
- );
202
- }
203
-
204
- const boldManager = kleur.bold(manager);
205
- const installCommand =
206
- manager === 'yarn' ? ` ${boldManager}` : ` ${boldManager} install`;
207
-
208
- const selectedTemplate = getTemplate(response.starter);
209
-
210
- if (!selectedTemplate) {
211
- throw Error(`Template ${response.starter.name} does not exist`);
212
- }
213
-
214
- if (selectedTemplate.startcommands === 'default') {
215
- console.log(installCommand);
216
- console.log(` ${boldManager} start`);
217
- } else {
218
- console.log(kleur.blue('\nNow find the setup instructions in README.md'));
219
- }
220
- console.log();
221
- }
222
-
223
- function isValidPackageName(projectName) {
224
- return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
225
- projectName,
226
- );
227
- }
228
-
229
- function copyDirectory(src, dest) {
230
- fs.mkdirSync(dest, {recursive: true});
231
- for (const file of fs.readdirSync(src)) {
232
- const srcFile = path.resolve(src, file);
233
- const destFile = path.resolve(dest, file);
234
- copy(srcFile, destFile);
235
- }
236
- }
237
-
238
- function copy(src, dest) {
239
- const stat = fs.statSync(src);
240
- if (stat.isDirectory()) {
241
- copyDirectory(src, dest);
242
- } else {
243
- fs.copyFileSync(src, dest);
244
- }
245
- }
246
-
247
- function getPackageManager() {
248
- const ua = process.env.npm_config_user_agent;
249
- return ua?.split(' ')[0].split('/')[0] ?? 'npm';
250
- }
251
-
252
- function getTemplate(value) {
253
- return templates.find(template => template.value === value);
254
- }
255
-
256
- void run().catch(e => {
257
- console.error(e);
258
- sendEvent(EventName.Error, {error: e});
259
- process.exit(1);
260
- });
1
+ #!/usr/bin/env node
2
+ //@ts-check
3
+ import {EventName, sendEvent} from '@twick/telemetry';
4
+ import fs from 'fs';
5
+ import kleur from 'kleur';
6
+ import minimist from 'minimist';
7
+ import {fileURLToPath} from 'node:url';
8
+ import path from 'path';
9
+ import prompts from 'prompts';
10
+
11
+ const templates = [
12
+ {
13
+ value: 'default',
14
+ title: 'Minimal, standalone Twick project',
15
+ description: 'A minimal example to get started with Twick.',
16
+ recommended: true,
17
+ startcommands: 'default',
18
+ },
19
+ {
20
+ value: 'saas-template',
21
+ title: 'Twick with Next.js',
22
+ description: 'A minimal web app built with Twick and Next.js.',
23
+ recommended: true,
24
+ startcommands: 'readme',
25
+ },
26
+ {
27
+ value: 'avatar-with-background',
28
+ title: 'Avatar with Background',
29
+ description: 'Create an avatar with a custom background.',
30
+ startcommands: 'default',
31
+ },
32
+ {
33
+ value: 'github-stars-celebration',
34
+ title: 'GitHub Stars Celebration',
35
+ description: 'Animate a celebration of GitHub repository stars.',
36
+ startcommands: 'default',
37
+ },
38
+ {
39
+ value: 'marketing-templates',
40
+ title: 'Marketing Templates',
41
+ description: 'A collection of templates for marketing videos.',
42
+ startcommands: 'readme',
43
+ },
44
+ {
45
+ value: 'minimal-drag-drop',
46
+ title: 'Drag and Drop Example',
47
+ description:
48
+ 'A minimal example of an editor with drag-and-drop editing functionality.',
49
+ startcommands: 'readme',
50
+ },
51
+ {
52
+ value: 'parallelized-aws-lambda',
53
+ title: 'Parallelized AWS Lambda',
54
+ description: 'Example of parallelized rendering using AWS Lambda.',
55
+ startcommands: 'readme',
56
+ },
57
+ {
58
+ value: 'rive-explanation-video',
59
+ title: 'Rive Explanation Video',
60
+ description: 'Create a code explanation video along with Rive animations.',
61
+ startcommands: 'default',
62
+ },
63
+ {
64
+ value: 'stitching-videos',
65
+ title: 'Stitching Videos',
66
+ description: 'Example of how to concatenate multiple videos together.',
67
+ startcommands: 'default',
68
+ },
69
+ {
70
+ value: 'three-js-example',
71
+ title: 'Three.js Example',
72
+ description: 'Integrate Three.js with Twick for 3D animations.',
73
+ startcommands: 'default',
74
+ },
75
+ {
76
+ value: 'youtube-shorts',
77
+ title: 'YouTube Shorts',
78
+ description: 'Template for creating YouTube Shorts videos.',
79
+ startcommands: 'default',
80
+ },
81
+ ];
82
+
83
+ async function run() {
84
+ const options = minimist(process.argv.slice(2));
85
+
86
+ const templateFlag = Object.keys(options).find(key =>
87
+ templates.some(template => template.value === key),
88
+ );
89
+
90
+ const pathResponse = await prompts([
91
+ // Prompt for project name
92
+ {
93
+ type: 'text',
94
+ name: 'name',
95
+ message: 'Project name',
96
+ initial: 'my-twick-project',
97
+ validate: value =>
98
+ isValidPackageName(value)
99
+ ? true
100
+ : 'Project name must be a valid npm package name.',
101
+ },
102
+ // Prompt for project path
103
+ {
104
+ type: 'text',
105
+ name: 'path',
106
+ message: 'Project path',
107
+
108
+ initial: value => {
109
+ return path.normalize(value.replace('@', ''));
110
+ },
111
+
112
+ validate: value => {
113
+ let dir = path.normalize(value.trim());
114
+ if (!fs.existsSync(dir)) {
115
+ return true;
116
+ }
117
+ if (!fs.lstatSync(dir).isDirectory()) {
118
+ return `Project path "${dir}" must be a valid directory.`;
119
+ }
120
+ if (fs.readdirSync(dir).length > 0) {
121
+ return dir === '.'
122
+ ? 'Current directory must be empty.'
123
+ : `Target directory "${dir}" must be empty.`;
124
+ }
125
+ return true;
126
+ },
127
+ format: value => path.resolve(value),
128
+ },
129
+ ]);
130
+
131
+ console.log(); // linebreak for better readability
132
+
133
+ let templateResponse;
134
+ if (templateFlag) {
135
+ templateResponse = {starter: templateFlag};
136
+ } else {
137
+ // Prompt for which example to scaffold
138
+ templateResponse = await prompts([
139
+ {
140
+ type: 'select',
141
+ name: 'starter',
142
+ message: 'Choose a starter template',
143
+ choices: templates.map(template => ({
144
+ title: template.recommended
145
+ ? template.title + kleur.bold(' (Recommended)')
146
+ : template.title,
147
+ value: template.value,
148
+ description: template.description,
149
+ })),
150
+ },
151
+ ]);
152
+ }
153
+
154
+ const response = {...pathResponse, ...templateResponse};
155
+
156
+ // Abort if the user didn't provide a project name
157
+ if (!response.path) {
158
+ console.log(kleur.red('× Scaffolding aborted by the user.\n'));
159
+ return;
160
+ }
161
+
162
+ console.log('Scaffolding, this can take a few seconds...');
163
+
164
+ // Clone files
165
+ const templateDir = path.resolve(
166
+ fileURLToPath(import.meta.url),
167
+ '..',
168
+ `examples/${response.starter}`,
169
+ );
170
+ copyDirectory(templateDir, response.path);
171
+
172
+ sendEvent(EventName.CreateCommand, {
173
+ name: response.name,
174
+ starter: response.starter,
175
+ });
176
+
177
+ // Read package.json and modify name
178
+ try {
179
+ const manifest = JSON.parse(
180
+ fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8'),
181
+ );
182
+ manifest.name = response.name;
183
+ fs.writeFileSync(
184
+ path.join(response.path, 'package.json'),
185
+ JSON.stringify(manifest, undefined, 2),
186
+ );
187
+ } catch (e) {
188
+ // Example doesn't have a package.json file
189
+ }
190
+
191
+ // Tell user that the process is complete
192
+ const manager = getPackageManager();
193
+ console.log(
194
+ kleur.green(
195
+ '\n√ Scaffolding complete. Run the following commands to get started:',
196
+ ),
197
+ );
198
+ if (response.path !== process.cwd()) {
199
+ console.log(
200
+ ` ${kleur.bold('cd')} ${path.relative(process.cwd(), response.path)}`,
201
+ );
202
+ }
203
+
204
+ const boldManager = kleur.bold(manager);
205
+ const installCommand =
206
+ manager === 'yarn' ? ` ${boldManager}` : ` ${boldManager} install`;
207
+
208
+ const selectedTemplate = getTemplate(response.starter);
209
+
210
+ if (!selectedTemplate) {
211
+ throw Error(`Template ${response.starter.name} does not exist`);
212
+ }
213
+
214
+ if (selectedTemplate.startcommands === 'default') {
215
+ console.log(installCommand);
216
+ console.log(` ${boldManager} start`);
217
+ } else {
218
+ console.log(kleur.blue('\nNow find the setup instructions in README.md'));
219
+ }
220
+ console.log();
221
+ }
222
+
223
+ function isValidPackageName(projectName) {
224
+ return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
225
+ projectName,
226
+ );
227
+ }
228
+
229
+ function copyDirectory(src, dest) {
230
+ fs.mkdirSync(dest, {recursive: true});
231
+ for (const file of fs.readdirSync(src)) {
232
+ const srcFile = path.resolve(src, file);
233
+ const destFile = path.resolve(dest, file);
234
+ copy(srcFile, destFile);
235
+ }
236
+ }
237
+
238
+ function copy(src, dest) {
239
+ const stat = fs.statSync(src);
240
+ if (stat.isDirectory()) {
241
+ copyDirectory(src, dest);
242
+ } else {
243
+ fs.copyFileSync(src, dest);
244
+ }
245
+ }
246
+
247
+ function getPackageManager() {
248
+ const ua = process.env.npm_config_user_agent;
249
+ return ua?.split(' ')[0].split('/')[0] ?? 'npm';
250
+ }
251
+
252
+ function getTemplate(value) {
253
+ return templates.find(template => template.value === value);
254
+ }
255
+
256
+ void run().catch(e => {
257
+ console.error(e);
258
+ sendEvent(EventName.Error, {error: e});
259
+ process.exit(1);
260
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twick/create",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "description": "Quickly scaffold twick projects",
5
5
  "main": "index.js",
6
6
  "author": "twick",
@@ -20,17 +20,17 @@
20
20
  "url": "https://github.com/ncounterspecialist/twick-base.git"
21
21
  },
22
22
  "devDependencies": {
23
- "@twick/2d": "^0.14.0",
24
- "@twick/core": "^0.14.0",
25
- "@twick/ffmpeg": "^0.14.0",
26
- "@twick/renderer": "^0.14.0",
27
- "@twick/ui": "^0.14.0",
28
- "@twick/vite-plugin": "^0.14.0"
23
+ "@twick/2d": "0.14.2",
24
+ "@twick/core": "0.14.2",
25
+ "@twick/ffmpeg": "0.14.2",
26
+ "@twick/renderer": "0.14.2",
27
+ "@twick/ui": "0.14.2",
28
+ "@twick/vite-plugin": "0.14.2"
29
29
  },
30
30
  "dependencies": {
31
- "@twick/telemetry": "^0.14.0",
31
+ "@twick/telemetry": "0.14.2",
32
32
  "minimist": "^1.2.8",
33
33
  "prompts": "^2.4.2"
34
34
  },
35
- "gitHead": "54bd58bf80ea6afec48c27c061e6d455c1e0a885"
35
+ "gitHead": "d07b1f841f3788e7c37b9672e54168d8a1ea75e5"
36
36
  }