@codellyson/create-framely 0.1.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/index.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const templateDir = path.join(__dirname, 'template');
9
+
10
+ const projectName = process.argv[2];
11
+
12
+ if (!projectName) {
13
+ console.error('Usage: create-framely <project-name>');
14
+ console.error('Example: npx create-framely my-video');
15
+ process.exit(1);
16
+ }
17
+
18
+ const targetDir = path.resolve(process.cwd(), projectName);
19
+
20
+ if (fs.existsSync(targetDir)) {
21
+ console.error(`Error: Directory "${projectName}" already exists.`);
22
+ process.exit(1);
23
+ }
24
+
25
+ /**
26
+ * Recursively copy a directory, replacing {{PROJECT_NAME}} in file contents.
27
+ */
28
+ function copyDir(src, dest) {
29
+ fs.mkdirSync(dest, { recursive: true });
30
+ const entries = fs.readdirSync(src, { withFileTypes: true });
31
+
32
+ for (const entry of entries) {
33
+ const srcPath = path.join(src, entry.name);
34
+ const destPath = path.join(dest, entry.name);
35
+
36
+ if (entry.isDirectory()) {
37
+ copyDir(srcPath, destPath);
38
+ } else {
39
+ let content = fs.readFileSync(srcPath, 'utf-8');
40
+ content = content.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
41
+ fs.writeFileSync(destPath, content);
42
+ }
43
+ }
44
+ }
45
+
46
+ console.log(`\nCreating a new Framely project in ${targetDir}\n`);
47
+
48
+ copyDir(templateDir, targetDir);
49
+
50
+ console.log('Done! To get started:\n');
51
+ console.log(` cd ${projectName}`);
52
+ console.log(' npm install');
53
+ console.log(' npx framely preview\n');
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@codellyson/create-framely",
3
+ "version": "0.1.0",
4
+ "description": "Create a new Framely video project",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-framely": "./index.js"
8
+ },
9
+ "files": [
10
+ "index.js",
11
+ "template/"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/codellyson/framely.git",
16
+ "directory": "packages/create-framely"
17
+ },
18
+ "homepage": "https://github.com/codellyson/framely#readme",
19
+ "author": "codellyson",
20
+ "keywords": [
21
+ "framely",
22
+ "video",
23
+ "react",
24
+ "create",
25
+ "scaffold"
26
+ ],
27
+ "license": "MIT"
28
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Framely Configuration
3
+ *
4
+ * Uncomment and modify settings as needed.
5
+ * See https://github.com/codellyson/framely#readme for documentation.
6
+ */
7
+
8
+ export default {
9
+ // Rendering
10
+ // codec: 'h264',
11
+ // crf: 18,
12
+ // fps: 30,
13
+
14
+ // Output
15
+ // outputDir: './outputs',
16
+
17
+ // Studio
18
+ // studioPort: 3000,
19
+ };
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "framely preview",
8
+ "studio": "framely preview",
9
+ "render": "framely render",
10
+ "still": "framely still"
11
+ },
12
+ "dependencies": {
13
+ "@codellyson/framely": "^0.1.0",
14
+ "@codellyson/framely-cli": "^0.1.0",
15
+ "react": "^18.2.0",
16
+ "react-dom": "^18.2.0"
17
+ }
18
+ }
File without changes
@@ -0,0 +1,18 @@
1
+ import { Composition } from '@codellyson/framely';
2
+ import { HelloWorld } from './compositions/HelloWorld';
3
+
4
+ export function Root() {
5
+ return (
6
+ <>
7
+ <Composition
8
+ id="hello-world"
9
+ component={HelloWorld}
10
+ width={1920}
11
+ height={1080}
12
+ fps={30}
13
+ durationInFrames={150}
14
+ defaultProps={{}}
15
+ />
16
+ </>
17
+ );
18
+ }
@@ -0,0 +1,52 @@
1
+ import {
2
+ useCurrentFrame,
3
+ useVideoConfig,
4
+ interpolate,
5
+ spring,
6
+ AbsoluteFill,
7
+ } from '@codellyson/framely';
8
+
9
+ export function HelloWorld() {
10
+ const frame = useCurrentFrame();
11
+ const { fps } = useVideoConfig();
12
+
13
+ const opacity = interpolate(frame, [0, 30], [0, 1], {
14
+ extrapolateRight: 'clamp',
15
+ });
16
+
17
+ const scale = spring({ frame, fps, from: 0.8, to: 1 });
18
+
19
+ return (
20
+ <AbsoluteFill
21
+ style={{
22
+ backgroundColor: '#0f0f0f',
23
+ justifyContent: 'center',
24
+ alignItems: 'center',
25
+ }}
26
+ >
27
+ <div style={{ opacity, transform: `scale(${scale})`, textAlign: 'center' }}>
28
+ <h1
29
+ style={{
30
+ color: 'white',
31
+ fontSize: 80,
32
+ fontFamily: 'system-ui, sans-serif',
33
+ fontWeight: 700,
34
+ margin: 0,
35
+ }}
36
+ >
37
+ Hello, Framely!
38
+ </h1>
39
+ <p
40
+ style={{
41
+ color: '#888',
42
+ fontSize: 24,
43
+ fontFamily: 'system-ui, sans-serif',
44
+ marginTop: 16,
45
+ }}
46
+ >
47
+ Edit src/compositions/HelloWorld.jsx to get started
48
+ </p>
49
+ </div>
50
+ </AbsoluteFill>
51
+ );
52
+ }
@@ -0,0 +1,4 @@
1
+ import { registerRoot } from '@codellyson/framely';
2
+ import { Root } from './Root';
3
+
4
+ registerRoot(Root);