@automerge/create-repo-node-app 1.0.15

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/.eslintrc ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2021": true
5
+ },
6
+ "extends": [
7
+ "eslint:recommended",
8
+ "plugin:@typescript-eslint/eslint-recommended",
9
+ "plugin:@typescript-eslint/recommended"
10
+ ],
11
+ "ignorePatterns": ["dist/**", "test/**", "node_modules/**"],
12
+ "parser": "@typescript-eslint/parser",
13
+ "plugins": ["@typescript-eslint"],
14
+ "parserOptions": {
15
+ "project": "./tsconfig.json",
16
+ "ecmaVersion": "latest",
17
+ "sourceType": "module"
18
+ },
19
+ "rules": {
20
+ "semi": ["error", "never"],
21
+ "import/extensions": 0,
22
+ "lines-between-class-members": 0,
23
+ "@typescript-eslint/no-floating-promises": "error",
24
+ "@typescript-eslint/no-empty-function": ["warn", { "allow": ["methods"] }],
25
+ "no-param-reassign": 0,
26
+ "no-use-before-define": 0
27
+ }
28
+ }
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2019-2023, Ink & Switch LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # Scaffolding for a node `automerge-repo` app
2
+
3
+ This generates a simple javascript project with the necessary dependencies for a repo which synchronises over websockets and stores data in the filesystem.
4
+
5
+ ## How to use
6
+
7
+ ### NPM
8
+
9
+ ```
10
+ npm create @automerge/repo-node-app <your project name>
11
+ ```
12
+
13
+ ### Yarn
14
+
15
+ ```
16
+ yarn create @automerge/repo-node-app <your project name>
17
+ ```
18
+
19
+ Now change into the directory and start editing `index.js`
20
+
21
+
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ // This is needed to tell your system that this file is a Node script.
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import child_process from 'child_process';
6
+ const execSync = child_process.execSync;
7
+ function createPackageJson(projectName) {
8
+ const packageJson = {
9
+ name: projectName,
10
+ version: '1.0.0',
11
+ description: '',
12
+ main: 'index.js',
13
+ type: 'module',
14
+ scripts: {
15
+ start: 'node index.js',
16
+ },
17
+ dependencies: {
18
+ '@automerge/automerge-repo': '^0.1',
19
+ '@automerge/automerge-repo-network-websocket': '^0.1',
20
+ '@automerge/automerge-repo-storage-nodefs': '^0.1',
21
+ },
22
+ };
23
+ fs.writeFileSync(path.join(projectName, 'package.json'), JSON.stringify(packageJson, null, 2) + '\n');
24
+ }
25
+ function createIndexJs(projectName) {
26
+ const indexJsContent = `import { Repo } from "@automerge/automerge-repo"
27
+ import { BrowserWebSocketClientAdapter } from "@automerge/automerge-repo-network-websocket"
28
+ import { NodeFSStorageAdapter } from "@automerge/automerge-repo-storage-nodefs"
29
+ import { next as Automerge } from "@automerge/automerge"
30
+
31
+ const repo = new Repo({
32
+ storage: [new NodeFSStorageAdapter("./db")],
33
+ network: [new BrowserWebSocketClientAdapter("wss://sync.automerge.org")]
34
+ })
35
+ `;
36
+ fs.writeFileSync(path.join(projectName, 'index.js'), indexJsContent);
37
+ }
38
+ function main() {
39
+ const projectName = process.argv[2];
40
+ if (!projectName) {
41
+ console.error('Please provide a project name');
42
+ process.exit(1);
43
+ }
44
+ fs.mkdirSync(projectName);
45
+ createPackageJson(projectName);
46
+ createIndexJs(projectName);
47
+ execSync(`cd ${projectName} && npm install`, { stdio: 'inherit' });
48
+ }
49
+ main();
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@automerge/create-repo-node-app",
3
+ "version": "1.0.15",
4
+ "description": "Create an automerge-repo app for node",
5
+ "repository": "https://github.com/automerge/automerge-repo/tree/master/packages/create-repo-node-app",
6
+ "author": "Alex Good <alex@memoryandthought.me>",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "bin": "dist/index.js",
10
+ "scripts": {
11
+ "build": "tsc && chmod a+x dist/index.js",
12
+ "watch": "npm-watch build"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "gitHead": "f60bd2a4594cc23b0ee6debed62aea61fb48ea56"
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ // This is needed to tell your system that this file is a Node script.
3
+
4
+ import fs from 'fs'
5
+ import path from 'path'
6
+ import child_process from 'child_process'
7
+
8
+ const execSync = child_process.execSync
9
+
10
+ function createPackageJson(projectName: string) {
11
+ const packageJson = {
12
+ name: projectName,
13
+ version: '1.0.0',
14
+ description: '',
15
+ main: 'index.js',
16
+ type: 'module',
17
+ scripts: {
18
+ start: 'node index.js',
19
+ },
20
+ dependencies: {
21
+ '@automerge/automerge-repo': '^0.1',
22
+ '@automerge/automerge-repo-network-websocket': '^0.1',
23
+ '@automerge/automerge-repo-storage-nodefs': '^0.1',
24
+ },
25
+ }
26
+ fs.writeFileSync(
27
+ path.join(projectName, 'package.json'),
28
+ JSON.stringify(packageJson, null, 2) + '\n'
29
+ )
30
+ }
31
+
32
+ function createIndexJs(projectName: string) {
33
+ const indexJsContent = `import { Repo } from "@automerge/automerge-repo"
34
+ import { BrowserWebSocketClientAdapter } from "@automerge/automerge-repo-network-websocket"
35
+ import { NodeFSStorageAdapter } from "@automerge/automerge-repo-storage-nodefs"
36
+ import { next as Automerge } from "@automerge/automerge"
37
+
38
+ const repo = new Repo({
39
+ storage: [new NodeFSStorageAdapter("./db")],
40
+ network: [new BrowserWebSocketClientAdapter("wss://sync.automerge.org")]
41
+ })
42
+ `
43
+ fs.writeFileSync(path.join(projectName, 'index.js'), indexJsContent)
44
+ }
45
+
46
+ function main() {
47
+ const projectName = process.argv[2]
48
+ if (!projectName) {
49
+ console.error('Please provide a project name')
50
+ process.exit(1)
51
+ }
52
+
53
+ fs.mkdirSync(projectName)
54
+ createPackageJson(projectName)
55
+ createIndexJs(projectName)
56
+ execSync(`cd ${projectName} && npm install`, { stdio: 'inherit' })
57
+ }
58
+
59
+ main()
60
+
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "jsx": "react",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "Node16",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "outDir": "./dist",
10
+ "esModuleInterop": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "strict": true,
13
+ "skipLibCheck": true
14
+ },
15
+ "include": ["src/**/*.ts"],
16
+ "exclude": ["dist"]
17
+ }