@revideo/create 0.3.4 → 0.3.5-alpha.964

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/index.js CHANGED
@@ -7,53 +7,21 @@ import {fileURLToPath} from 'node:url';
7
7
  import path from 'path';
8
8
  import prompts from 'prompts';
9
9
 
10
- const FILES_TO_MODIFY = {
11
- gitignore: '.gitignore',
12
- '.gitkeep': false,
13
- };
14
-
15
- const MANIFEST = JSON.parse(
16
- fs.readFileSync(
17
- path.resolve(fileURLToPath(import.meta.url), '../package.json'),
18
- 'utf-8',
19
- ),
20
- );
21
-
22
- const PLUGINS = {
23
- core: {
24
- package: '@revideo/vite-plugin',
25
- variable: 'motionCanvas',
26
- options: response =>
27
- response.language === 'js' ? `{project: './src/project.js'}` : '',
28
- },
29
- };
30
-
31
- (async () => {
10
+ const templates = [
11
+ 'default',
12
+ 'avatar-with-background',
13
+ 'google-cloud-run',
14
+ 'google-cloud-run-parallelized',
15
+ 'stitching-videos',
16
+ 'youtube-shorts',
17
+ ];
18
+
19
+ async function run() {
32
20
  const options = minimist(process.argv.slice(2));
33
- if (options.plugins !== undefined) {
34
- if (typeof options.plugins === 'string') {
35
- options.plugins = options.plugins.split(',');
36
- }
37
-
38
- if (!Array.isArray(options.plugins)) {
39
- options.plugins = [options.plugins];
40
- }
41
-
42
- const plugins = ['core'];
43
- for (const plugin of options.plugins) {
44
- if (plugin === 'core') continue;
45
- if (!(plugin in PLUGINS)) {
46
- console.log(kleur.yellow(`! Unknown plugin "${plugin}".\n`));
47
- continue;
48
- }
49
- plugins.push(plugin);
50
- }
51
-
52
- options.plugins = plugins;
53
- }
54
21
 
55
22
  prompts.override(options);
56
23
  const response = await prompts([
24
+ // Prompt for project name
57
25
  {
58
26
  type: 'text',
59
27
  name: 'name',
@@ -64,6 +32,7 @@ const PLUGINS = {
64
32
  ? true
65
33
  : 'Project name must be a valid npm package name.',
66
34
  },
35
+ // Prompt for project path
67
36
  {
68
37
  type: 'text',
69
38
  name: 'path',
@@ -90,42 +59,46 @@ const PLUGINS = {
90
59
  },
91
60
  format: value => path.resolve(value),
92
61
  },
62
+ // Prompt for which example to scaffold
63
+ {
64
+ type: 'select',
65
+ name: 'starter',
66
+ message: 'Choose a starter template',
67
+
68
+ choices: [
69
+ ...templates.map(template => ({title: template, value: template})),
70
+ ],
71
+ },
93
72
  ]);
94
73
 
74
+ // Abort if the user didn't provide a project name
95
75
  if (!response.path) {
96
76
  console.log(kleur.red('× Scaffolding aborted by the user.\n'));
97
77
  return;
98
78
  }
99
79
 
100
- const plugins = [PLUGINS.core];
80
+ console.log(`the response is ${JSON.stringify(response)}`);
81
+
82
+ // Clone files
101
83
  const templateDir = path.resolve(
102
84
  fileURLToPath(import.meta.url),
103
85
  '..',
104
- `template-2d-ts`,
86
+ `examples/${response.starter}`,
105
87
  );
106
88
  copyDirectory(templateDir, response.path);
107
- createConfig(response, plugins);
89
+ createConfig(response);
108
90
 
91
+ // Read package.json and modify name
109
92
  const manifest = JSON.parse(
110
93
  fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8'),
111
94
  );
112
95
  manifest.name = response.name;
113
- manifest.dependencies ??= {};
114
- for (const data of plugins) {
115
- if (data.version) {
116
- manifest.dependencies[data.package] = data.version;
117
- }
118
- }
119
- cloneVersions(manifest.dependencies);
120
-
121
- if (manifest.devDependencies) {
122
- cloneVersions(manifest.devDependencies);
123
- }
124
96
  fs.writeFileSync(
125
97
  path.join(response.path, 'package.json'),
126
98
  JSON.stringify(manifest, undefined, 2),
127
99
  );
128
100
 
101
+ // Tell user that the process is complete
129
102
  const manager = getPackageManager();
130
103
  console.log(kleur.green('\n√ Scaffolding complete. You can now run:'));
131
104
  if (response.path !== process.cwd()) {
@@ -142,7 +115,7 @@ const PLUGINS = {
142
115
  console.log(` ${boldManager} start`);
143
116
  }
144
117
  console.log();
145
- })();
118
+ }
146
119
 
147
120
  function isValidPackageName(projectName) {
148
121
  return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
@@ -153,13 +126,8 @@ function isValidPackageName(projectName) {
153
126
  function copyDirectory(src, dest) {
154
127
  fs.mkdirSync(dest, {recursive: true});
155
128
  for (const file of fs.readdirSync(src)) {
156
- let target = file;
157
- if (file in FILES_TO_MODIFY) {
158
- if (FILES_TO_MODIFY[file] === false) continue;
159
- target = FILES_TO_MODIFY[file];
160
- }
161
129
  const srcFile = path.resolve(src, file);
162
- const destFile = path.resolve(dest, target);
130
+ const destFile = path.resolve(dest, file);
163
131
  copy(srcFile, destFile);
164
132
  }
165
133
  }
@@ -173,27 +141,17 @@ function copy(src, dest) {
173
141
  }
174
142
  }
175
143
 
176
- function createConfig(response, selectedPlugins) {
177
- const imports = [];
178
- const plugins = [];
179
- for (const data of selectedPlugins) {
180
- imports.push(`import ${data.variable} from '${data.package}';\n`);
181
- plugins.push(`${data.variable}(${data.options?.(response) ?? ''}),`);
182
- }
183
-
144
+ function createConfig(response) {
184
145
  const configFile = path.resolve(response.path, `vite.config.ts`);
185
146
 
186
147
  fs.writeFileSync(
187
148
  configFile,
188
- `import {defineConfig} from 'vite';
189
- ${imports.join('')}
190
-
191
- export default defineConfig({
192
- plugins: [
193
- ${plugins.join('\n ')}
194
- ],
195
- });
196
- `,
149
+ `import motionCanvas from '@revideo/vite-plugin';
150
+ import {defineConfig} from 'vite';
151
+
152
+ export default defineConfig({
153
+ plugins: [motionCanvas()],
154
+ });`,
197
155
  );
198
156
  }
199
157
 
@@ -202,13 +160,4 @@ function getPackageManager() {
202
160
  return ua?.split(' ')[0].split('/')[0] ?? 'npm';
203
161
  }
204
162
 
205
- function cloneVersions(versions) {
206
- for (const dependency in versions) {
207
- if (
208
- dependency.startsWith('@revideo') &&
209
- MANIFEST.devDependencies[dependency]
210
- ) {
211
- versions[dependency] = MANIFEST.devDependencies[dependency];
212
- }
213
- }
214
- }
163
+ void run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revideo/create",
3
- "version": "0.3.4",
3
+ "version": "0.3.5-alpha.964+4f114fa",
4
4
  "description": "Quickly scaffold revideo projects",
5
5
  "main": "index.js",
6
6
  "author": "revideo",
@@ -20,16 +20,16 @@
20
20
  "url": "https://github.com/havenhq/revideo.git"
21
21
  },
22
22
  "devDependencies": {
23
- "@revideo/2d": "0.3.4",
24
- "@revideo/core": "0.3.4",
25
- "@revideo/ffmpeg": "0.3.4",
26
- "@revideo/renderer": "0.3.4",
27
- "@revideo/ui": "0.3.4",
28
- "@revideo/vite-plugin": "0.3.4"
23
+ "@revideo/2d": "^0.3.5-alpha.964+4f114fa",
24
+ "@revideo/core": "^0.3.5-alpha.964+4f114fa",
25
+ "@revideo/ffmpeg": "^0.3.5-alpha.964+4f114fa",
26
+ "@revideo/renderer": "^0.3.5-alpha.964+4f114fa",
27
+ "@revideo/ui": "^0.3.5-alpha.964+4f114fa",
28
+ "@revideo/vite-plugin": "^0.3.5-alpha.964+4f114fa"
29
29
  },
30
30
  "dependencies": {
31
31
  "minimist": "^1.2.8",
32
32
  "prompts": "^2.4.2"
33
33
  },
34
- "gitHead": "dffb2ff7846d4f2481a5613a9a193ec81551ced5"
34
+ "gitHead": "4f114fa70b4973972ed0bf9ef99effc90941a339"
35
35
  }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "2d-starter",
3
- "private": true,
4
- "version": "0.0.0",
5
- "scripts": {
6
- "start": "vite",
7
- "serve": "vite",
8
- "build": "tsc && vite build",
9
- "render": "tsc && node dist/render.js"
10
- },
11
- "dependencies": {
12
- "@revideo/core": "^0.3.4",
13
- "@revideo/2d": "^0.3.4",
14
- "@revideo/renderer": "^0.3.4",
15
- "@revideo/vite-plugin": "^0.3.4",
16
- "@revideo/ffmpeg": "^0.3.4"
17
- },
18
- "devDependencies": {
19
- "@revideo/ui": "^0.3.4",
20
- "@revideo/cli": "^0.3.4",
21
- "typescript": "^5.2.2",
22
- "vite": "^4.5"
23
- }
24
- }
File without changes
@@ -1,31 +0,0 @@
1
- {
2
- "version": 0,
3
- "shared": {
4
- "background": null,
5
- "range": [
6
- 0,
7
- null
8
- ],
9
- "size": {
10
- "x": 1920,
11
- "y": 1080
12
- },
13
- "audioOffset": 0
14
- },
15
- "preview": {
16
- "fps": 30,
17
- "resolutionScale": 1
18
- },
19
- "rendering": {
20
- "fps": 30,
21
- "resolutionScale": 1,
22
- "colorSpace": "srgb",
23
- "exporter": {
24
- "name": "@revideo/ffmpeg",
25
- "options": {
26
- "fastStart": true,
27
- "includeAudio": true
28
- }
29
- }
30
- }
31
- }
@@ -1,7 +0,0 @@
1
- import {makeProject} from '@revideo/core';
2
-
3
- import example from './scenes/example?scene';
4
-
5
- export default makeProject({
6
- scenes: [example],
7
- });
@@ -1,17 +0,0 @@
1
- import {renderVideo} from '@revideo/renderer';
2
-
3
- async function render() {
4
- console.log('Rendering video...');
5
-
6
- // This is the main function that renders the video
7
- const file = await renderVideo(
8
- './vite.config.ts',
9
- {fill: 'orange'},
10
- () => {},
11
- {logProgress: true},
12
- );
13
-
14
- console.log(`Rendered video to ${file}`);
15
- }
16
-
17
- render();
@@ -1 +0,0 @@
1
- /// <reference types="@revideo/core/project" />
@@ -1,38 +0,0 @@
1
- import {Audio, Img, Video, makeScene2D} from '@revideo/2d';
2
- import {all, chain, createRef, waitFor} from '@revideo/core';
3
-
4
- export default makeScene2D(function* (view) {
5
- const logoRef = createRef<Img>();
6
-
7
- yield view.add(
8
- <>
9
- <Video
10
- src={'https://revideo-example-assets.s3.amazonaws.com/stars.mp4'}
11
- size={['100%', '100%']}
12
- play={true}
13
- />
14
- <Audio
15
- src={'https://revideo-example-assets.s3.amazonaws.com/chill-beat.mp3'}
16
- play={true}
17
- time={17.0}
18
- />
19
- </>,
20
- );
21
-
22
- yield* waitFor(1);
23
-
24
- view.add(
25
- <Img
26
- width={'1%'}
27
- ref={logoRef}
28
- src={
29
- 'https://revideo-example-assets.s3.amazonaws.com/revideo-logo-white.png'
30
- }
31
- />,
32
- );
33
-
34
- yield* chain(
35
- all(logoRef().scale(40, 2), logoRef().rotation(360, 2)),
36
- logoRef().scale(60, 1),
37
- );
38
- });
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "@revideo/2d/tsconfig.project.json",
3
- "include": ["src"],
4
- "compilerOptions": {
5
- "noEmit": false,
6
- "outDir": "dist",
7
- "module": "CommonJS"
8
- }
9
- }