create-harper 0.0.2 → 0.0.3

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 (71) hide show
  1. package/README.md +5 -0
  2. package/index.js +37 -214
  3. package/lib/constants/renameFiles.js +1 -0
  4. package/lib/fs/applyAndWriteTemplateFile.js +5 -5
  5. package/lib/fs/crawlTemplateDir.js +3 -3
  6. package/lib/pkg/toValidPackageName.js +2 -1
  7. package/lib/steps/getEnvVars.js +79 -0
  8. package/lib/steps/getImmediate.js +29 -0
  9. package/lib/steps/getPackageName.js +38 -0
  10. package/lib/steps/getProjectName.js +40 -0
  11. package/lib/steps/getTemplate.js +65 -0
  12. package/lib/steps/handleExistingDir.js +61 -0
  13. package/lib/steps/scaffoldProject.js +40 -0
  14. package/lib/steps/showOutro.js +30 -0
  15. package/package.json +12 -8
  16. package/template-barebones/README.md +1 -1
  17. package/template-barebones/_env +3 -0
  18. package/template-barebones/_env.example +3 -0
  19. package/template-barebones/package.json +1 -1
  20. package/template-react/README.md +1 -1
  21. package/template-react/_aiignore +1 -0
  22. package/template-react/_env +3 -0
  23. package/template-react/_env.example +3 -0
  24. package/template-react/_github/workflow/deploy.yaml +1 -1
  25. package/template-react/_gitignore +147 -0
  26. package/template-react/graphql.config.yml +3 -0
  27. package/template-react/index.html +1 -1
  28. package/template-react/package.json +5 -4
  29. package/template-react-ts/README.md +1 -1
  30. package/template-react-ts/_aiignore +1 -0
  31. package/template-react-ts/_env +3 -0
  32. package/template-react-ts/_env.example +3 -0
  33. package/template-react-ts/_github/workflow/deploy.yaml +1 -1
  34. package/template-react-ts/_gitignore +147 -0
  35. package/template-react-ts/graphql.config.yml +3 -0
  36. package/template-react-ts/index.html +1 -1
  37. package/template-react-ts/package.json +5 -4
  38. package/template-studio/README.md +1 -1
  39. package/template-studio/_aiignore +1 -0
  40. package/template-studio/_gitignore +147 -0
  41. package/template-studio/graphql.config.yml +3 -0
  42. package/template-studio/package.json +1 -1
  43. package/template-studio/web/index.html +2 -2
  44. package/template-studio-ts/README.md +1 -1
  45. package/template-studio-ts/_aiignore +1 -0
  46. package/template-studio-ts/_gitignore +147 -0
  47. package/template-studio-ts/graphql.config.yml +3 -0
  48. package/template-studio-ts/package.json +1 -1
  49. package/template-studio-ts/web/index.html +2 -2
  50. package/template-vanilla/README.md +1 -1
  51. package/template-vanilla/_aiignore +1 -0
  52. package/template-vanilla/_env +3 -0
  53. package/template-vanilla/_env.example +3 -0
  54. package/template-vanilla/_gitignore +147 -0
  55. package/template-vanilla/graphql.config.yml +3 -0
  56. package/template-vanilla/package.json +1 -1
  57. package/template-vanilla/web/index.html +2 -2
  58. package/template-vanilla-ts/README.md +1 -1
  59. package/template-vanilla-ts/_aiignore +1 -0
  60. package/template-vanilla-ts/_env +3 -0
  61. package/template-vanilla-ts/_env.example +3 -0
  62. package/template-vanilla-ts/_gitignore +147 -0
  63. package/template-vanilla-ts/graphql.config.yml +3 -0
  64. package/template-vanilla-ts/package.json +1 -1
  65. package/template-vanilla-ts/web/index.html +2 -2
  66. package/lib/fs/editFile.js +0 -6
  67. package/lib/pkg/getFullCustomCommand.js +0 -47
  68. package/template-shared/_env.example +0 -3
  69. /package/{template-shared → template-barebones}/_aiignore +0 -0
  70. /package/{template-shared → template-barebones}/_gitignore +0 -0
  71. /package/{template-shared → template-barebones}/graphql.config.yml +0 -0
@@ -0,0 +1,40 @@
1
+ import * as prompts from '@clack/prompts';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { crawlTemplateDir } from '../fs/crawlTemplateDir.js';
6
+
7
+ /**
8
+ * Step 6: Write out the contents based on all prior steps.
9
+ * @param {string} targetDir
10
+ * @param {string} projectName
11
+ * @param {string} packageName
12
+ * @param {string} template
13
+ * @param {{username: string, target: string, password?: string}} envVars
14
+ * @returns {string} The root directory of the project
15
+ */
16
+ export function scaffoldProject(targetDir, projectName, packageName, template, envVars) {
17
+ const cwd = process.cwd();
18
+ const root = path.join(cwd, targetDir);
19
+ fs.mkdirSync(root, { recursive: true });
20
+ prompts.log.step(`Scaffolding project in ${root}...`);
21
+
22
+ const substitutions = {
23
+ 'your-project-name-here': projectName,
24
+ 'your-package-name-here': packageName,
25
+ 'your-cluster-username-here': envVars.username,
26
+ 'your-cluster-password-here': envVars.password,
27
+ 'your-fabric.harper.fast-cluster-url-here': envVars.target,
28
+ };
29
+
30
+ const templateDir = path.resolve(
31
+ fileURLToPath(import.meta.url),
32
+ '..',
33
+ '..',
34
+ '..',
35
+ `template-${template}`,
36
+ );
37
+ crawlTemplateDir(root, templateDir, substitutions);
38
+
39
+ return root;
40
+ }
@@ -0,0 +1,30 @@
1
+ import * as prompts from '@clack/prompts';
2
+ import path from 'node:path';
3
+ import { install } from '../install.js';
4
+ import { getInstallCommand } from '../pkg/getInstallCommand.js';
5
+ import { getRunCommand } from '../pkg/getRunCommand.js';
6
+ import { start } from '../start.js';
7
+
8
+ /**
9
+ * Step 7: Log out the next steps.
10
+ * @param {string} root
11
+ * @param {string} pkgManager
12
+ * @param {boolean} immediate
13
+ */
14
+ export function showOutro(root, pkgManager, immediate) {
15
+ if (immediate) {
16
+ install(root, pkgManager);
17
+ start(root, pkgManager);
18
+ } else {
19
+ let doneMessage = '';
20
+ const cwd = process.cwd();
21
+ const cdProjectName = path.relative(cwd, root);
22
+ doneMessage += `Done. Now run:\n`;
23
+ if (root !== cwd) {
24
+ doneMessage += `\n cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`;
25
+ }
26
+ doneMessage += `\n ${getInstallCommand(pkgManager).join(' ')}`;
27
+ doneMessage += `\n ${getRunCommand(pkgManager, 'dev').join(' ')}`;
28
+ prompts.outro(doneMessage);
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-harper",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "HarperDB",
@@ -13,22 +13,25 @@
13
13
  "files": [
14
14
  "index.js",
15
15
  "lib/",
16
+ "!lib/**/*.test.js",
16
17
  "template-barebones/",
17
18
  "template-react/",
18
19
  "template-react-ts/",
19
- "template-shared/",
20
20
  "template-studio/",
21
21
  "template-studio-ts/",
22
22
  "template-vanilla/",
23
23
  "template-vanilla-ts/"
24
24
  ],
25
25
  "scripts": {
26
- "lint": "oxlint .",
27
- "lint:fix": "oxlint . --fix",
28
- "format": "dprint check",
26
+ "commitlint": "commitlint --edit",
27
+ "format:check": "dprint check",
29
28
  "format:fix": "dprint fmt",
30
29
  "format:staged": "dprint check --staged",
31
- "test": "vitest"
30
+ "lint:check": "oxlint .",
31
+ "lint:fix": "oxlint . --fix",
32
+ "test": "vitest run",
33
+ "test:coverage": "vitest run --coverage",
34
+ "test:watch": "vitest"
32
35
  },
33
36
  "engines": {
34
37
  "node": "^20.19.0 || >=22.12.0"
@@ -45,13 +48,14 @@
45
48
  "@clack/prompts": "^1.0.0-alpha.9",
46
49
  "@vercel/detect-agent": "^1.0.0",
47
50
  "cross-spawn": "^7.0.6",
48
- "lodash": "^4.17.21",
49
51
  "mri": "^1.2.0",
50
52
  "picocolors": "^1.1.1"
51
53
  },
52
54
  "devDependencies": {
55
+ "@commitlint/cli": "^20.0.0",
56
+ "@commitlint/config-conventional": "^20.0.0",
57
+ "@vitest/coverage-v8": "^4.0.17",
53
58
  "dprint": "^0.51.1",
54
- "harperdb": "^4.7.15",
55
59
  "oxlint": "^1.38.0",
56
60
  "vitest": "^4.0.17"
57
61
  }
@@ -1,4 +1,4 @@
1
- # <<projectName>>
1
+ # your-project-name-here
2
2
 
3
3
  This repository is intended for use alongside the Harper Learn ["Getting Started > Create Your First Application"](https://docs.harperdb.io/learn/getting-started/create-your-first-application) guide.
4
4
 
@@ -0,0 +1,3 @@
1
+ CLI_TARGET_USERNAME='your-cluster-username-here'
2
+ CLI_TARGET_PASSWORD='your-cluster-password-here'
3
+ CLI_TARGET='your-fabric.harper.fast-cluster-url-here'
@@ -0,0 +1,3 @@
1
+ CLI_TARGET_USERNAME='YOUR_CLUSTER_USERNAME'
2
+ CLI_TARGET_PASSWORD='YOUR_CLUSTER_PASSWORD'
3
+ CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE'
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "<<packageName>>",
2
+ "name": "your-package-name-here",
3
3
  "version": "1.0.0",
4
4
  "description": "Your new Harper app",
5
5
  "type": "module",
@@ -1,4 +1,4 @@
1
- # <<projectName>>
1
+ # your-project-name-here
2
2
 
3
3
  ## Installation
4
4
 
@@ -0,0 +1 @@
1
+ .env
@@ -0,0 +1,3 @@
1
+ CLI_TARGET_USERNAME='your-cluster-username-here'
2
+ CLI_TARGET_PASSWORD='your-cluster-password-here'
3
+ CLI_TARGET='your-fabric.harper.fast-cluster-url-here'
@@ -0,0 +1,3 @@
1
+ CLI_TARGET_USERNAME='YOUR_CLUSTER_USERNAME'
2
+ CLI_TARGET_PASSWORD='YOUR_CLUSTER_PASSWORD'
3
+ CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE'
@@ -26,7 +26,7 @@ jobs:
26
26
  - name: Install dependencies
27
27
  run: npm ci
28
28
  - name: Run unit tests
29
- run: npm run test
29
+ run: npm test
30
30
  - name: Run lint
31
31
  run: npm run lint
32
32
  - name: Build
@@ -0,0 +1,147 @@
1
+ .DS_Store
2
+
3
+ #
4
+ # https://raw.githubusercontent.com/github/gitignore/refs/heads/main/Node.gitignore
5
+ #
6
+
7
+ # Logs
8
+ logs
9
+ *.log
10
+ npm-debug.log*
11
+ yarn-debug.log*
12
+ yarn-error.log*
13
+ lerna-debug.log*
14
+
15
+ # Diagnostic reports (https://nodejs.org/api/report.html)
16
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17
+
18
+ # Runtime data
19
+ pids
20
+ *.pid
21
+ *.seed
22
+ *.pid.lock
23
+
24
+ # Directory for instrumented libs generated by jscoverage/JSCover
25
+ lib-cov
26
+
27
+ # Coverage directory used by tools like istanbul
28
+ coverage
29
+ *.lcov
30
+
31
+ # nyc test coverage
32
+ .nyc_output
33
+
34
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35
+ .grunt
36
+
37
+ # Bower dependency directory (https://bower.io/)
38
+ bower_components
39
+
40
+ # node-waf configuration
41
+ .lock-wscript
42
+
43
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
44
+ build/Release
45
+
46
+ # Dependency directories
47
+ node_modules/
48
+ jspm_packages/
49
+
50
+ # Snowpack dependency directory (https://snowpack.dev/)
51
+ web_modules/
52
+
53
+ # TypeScript cache
54
+ *.tsbuildinfo
55
+
56
+ # Optional npm cache directory
57
+ .npm
58
+
59
+ # Optional eslint cache
60
+ .eslintcache
61
+
62
+ # Optional stylelint cache
63
+ .stylelintcache
64
+
65
+ # Optional REPL history
66
+ .node_repl_history
67
+
68
+ # Output of 'npm pack'
69
+ *.tgz
70
+
71
+ # Yarn Integrity file
72
+ .yarn-integrity
73
+
74
+ # dotenv environment variable files
75
+ .env
76
+ .env.*
77
+ !.env.example
78
+
79
+ # parcel-bundler cache (https://parceljs.org/)
80
+ .cache
81
+ .parcel-cache
82
+
83
+ # Next.js build output
84
+ .next
85
+ out
86
+
87
+ # Nuxt.js build / generate output
88
+ .nuxt
89
+ dist
90
+ .output
91
+
92
+ # Gatsby files
93
+ .cache/
94
+ # Comment in the public line in if your project uses Gatsby and not Next.js
95
+ # https://nextjs.org/blog/next-9-1#public-directory-support
96
+ # public
97
+
98
+ # vuepress build output
99
+ .vuepress/dist
100
+
101
+ # vuepress v2.x temp and cache directory
102
+ .temp
103
+ .cache
104
+
105
+ # Sveltekit cache directory
106
+ .svelte-kit/
107
+
108
+ # vitepress build output
109
+ **/.vitepress/dist
110
+
111
+ # vitepress cache directory
112
+ **/.vitepress/cache
113
+
114
+ # Docusaurus cache and generated files
115
+ .docusaurus
116
+
117
+ # Serverless directories
118
+ .serverless/
119
+
120
+ # FuseBox cache
121
+ .fusebox/
122
+
123
+ # DynamoDB Local files
124
+ .dynamodb/
125
+
126
+ # Firebase cache directory
127
+ .firebase/
128
+
129
+ # TernJS port file
130
+ .tern-port
131
+
132
+ # Stores VSCode versions used for testing VSCode extensions
133
+ .vscode-test
134
+
135
+ # yarn v3
136
+ .pnp.*
137
+ .yarn/*
138
+ !.yarn/patches
139
+ !.yarn/plugins
140
+ !.yarn/releases
141
+ !.yarn/sdks
142
+ !.yarn/versions
143
+
144
+ # Vite files
145
+ vite.config.js.timestamp-*
146
+ vite.config.ts.timestamp-*
147
+ .vite/
@@ -0,0 +1,3 @@
1
+ schema: schema.graphql
2
+ include: node_modules/harperdb/schema.graphql
3
+ documents: '**/*.graphql'
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title><<projectName>></title>
7
+ <title>your-project-name-here</title>
8
8
  </head>
9
9
  <body>
10
10
  <div id="app"></div>
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "<<packageName>>",
2
+ "name": "your-package-name-here",
3
3
  "private": true,
4
4
  "version": "0.0.0",
5
5
  "type": "module",
@@ -8,7 +8,8 @@
8
8
  "test": "echo 'No tests implemented yet'",
9
9
  "lint": "echo 'No lint implemented yet'",
10
10
  "build": "vite build",
11
- "preview": "vite preview"
11
+ "preview": "vite preview",
12
+ "deploy": "npx -y dotenv-cli -- harperdb deploy . restart=rolling replicated=true"
12
13
  },
13
14
  "devDependencies": {
14
15
  "@harperfast/vite-plugin": "^0.0.1",
@@ -16,9 +17,9 @@
16
17
  "harperdb": "^4.7.15",
17
18
  "react": "^19.2.3",
18
19
  "react-dom": "^19.2.3",
19
- "vite": "npm:rolldown-vite@7.2.5"
20
+ "vite": "npm:rolldown-vite@7.3.1"
20
21
  },
21
22
  "overrides": {
22
- "vite": "npm:rolldown-vite@7.2.5"
23
+ "vite": "npm:rolldown-vite@7.3.1"
23
24
  }
24
25
  }
@@ -1,4 +1,4 @@
1
- # <<projectName>>
1
+ # your-project-name-here
2
2
 
3
3
  ## Installation
4
4
 
@@ -0,0 +1 @@
1
+ .env
@@ -0,0 +1,3 @@
1
+ CLI_TARGET_USERNAME='your-cluster-username-here'
2
+ CLI_TARGET_PASSWORD='your-cluster-password-here'
3
+ CLI_TARGET='your-fabric.harper.fast-cluster-url-here'
@@ -0,0 +1,3 @@
1
+ CLI_TARGET_USERNAME='YOUR_CLUSTER_USERNAME'
2
+ CLI_TARGET_PASSWORD='YOUR_CLUSTER_PASSWORD'
3
+ CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE'
@@ -26,7 +26,7 @@ jobs:
26
26
  - name: Install dependencies
27
27
  run: npm ci
28
28
  - name: Run unit tests
29
- run: npm run test
29
+ run: npm test
30
30
  - name: Run lint
31
31
  run: npm run lint
32
32
  - name: Build
@@ -0,0 +1,147 @@
1
+ .DS_Store
2
+
3
+ #
4
+ # https://raw.githubusercontent.com/github/gitignore/refs/heads/main/Node.gitignore
5
+ #
6
+
7
+ # Logs
8
+ logs
9
+ *.log
10
+ npm-debug.log*
11
+ yarn-debug.log*
12
+ yarn-error.log*
13
+ lerna-debug.log*
14
+
15
+ # Diagnostic reports (https://nodejs.org/api/report.html)
16
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17
+
18
+ # Runtime data
19
+ pids
20
+ *.pid
21
+ *.seed
22
+ *.pid.lock
23
+
24
+ # Directory for instrumented libs generated by jscoverage/JSCover
25
+ lib-cov
26
+
27
+ # Coverage directory used by tools like istanbul
28
+ coverage
29
+ *.lcov
30
+
31
+ # nyc test coverage
32
+ .nyc_output
33
+
34
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35
+ .grunt
36
+
37
+ # Bower dependency directory (https://bower.io/)
38
+ bower_components
39
+
40
+ # node-waf configuration
41
+ .lock-wscript
42
+
43
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
44
+ build/Release
45
+
46
+ # Dependency directories
47
+ node_modules/
48
+ jspm_packages/
49
+
50
+ # Snowpack dependency directory (https://snowpack.dev/)
51
+ web_modules/
52
+
53
+ # TypeScript cache
54
+ *.tsbuildinfo
55
+
56
+ # Optional npm cache directory
57
+ .npm
58
+
59
+ # Optional eslint cache
60
+ .eslintcache
61
+
62
+ # Optional stylelint cache
63
+ .stylelintcache
64
+
65
+ # Optional REPL history
66
+ .node_repl_history
67
+
68
+ # Output of 'npm pack'
69
+ *.tgz
70
+
71
+ # Yarn Integrity file
72
+ .yarn-integrity
73
+
74
+ # dotenv environment variable files
75
+ .env
76
+ .env.*
77
+ !.env.example
78
+
79
+ # parcel-bundler cache (https://parceljs.org/)
80
+ .cache
81
+ .parcel-cache
82
+
83
+ # Next.js build output
84
+ .next
85
+ out
86
+
87
+ # Nuxt.js build / generate output
88
+ .nuxt
89
+ dist
90
+ .output
91
+
92
+ # Gatsby files
93
+ .cache/
94
+ # Comment in the public line in if your project uses Gatsby and not Next.js
95
+ # https://nextjs.org/blog/next-9-1#public-directory-support
96
+ # public
97
+
98
+ # vuepress build output
99
+ .vuepress/dist
100
+
101
+ # vuepress v2.x temp and cache directory
102
+ .temp
103
+ .cache
104
+
105
+ # Sveltekit cache directory
106
+ .svelte-kit/
107
+
108
+ # vitepress build output
109
+ **/.vitepress/dist
110
+
111
+ # vitepress cache directory
112
+ **/.vitepress/cache
113
+
114
+ # Docusaurus cache and generated files
115
+ .docusaurus
116
+
117
+ # Serverless directories
118
+ .serverless/
119
+
120
+ # FuseBox cache
121
+ .fusebox/
122
+
123
+ # DynamoDB Local files
124
+ .dynamodb/
125
+
126
+ # Firebase cache directory
127
+ .firebase/
128
+
129
+ # TernJS port file
130
+ .tern-port
131
+
132
+ # Stores VSCode versions used for testing VSCode extensions
133
+ .vscode-test
134
+
135
+ # yarn v3
136
+ .pnp.*
137
+ .yarn/*
138
+ !.yarn/patches
139
+ !.yarn/plugins
140
+ !.yarn/releases
141
+ !.yarn/sdks
142
+ !.yarn/versions
143
+
144
+ # Vite files
145
+ vite.config.js.timestamp-*
146
+ vite.config.ts.timestamp-*
147
+ .vite/
@@ -0,0 +1,3 @@
1
+ schema: schema.graphql
2
+ include: node_modules/harperdb/schema.graphql
3
+ documents: '**/*.graphql'
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title><<projectName>></title>
7
+ <title>your-project-name-here</title>
8
8
  </head>
9
9
  <body>
10
10
  <div id="app"></div>
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "<<packageName>>",
2
+ "name": "your-package-name-here",
3
3
  "private": true,
4
4
  "version": "0.0.0",
5
5
  "type": "module",
@@ -8,7 +8,8 @@
8
8
  "test": "echo 'No tests implemented yet'",
9
9
  "lint": "echo 'No lint implemented yet'",
10
10
  "build": "tsc -b && vite build",
11
- "preview": "vite preview"
11
+ "preview": "vite preview",
12
+ "deploy": "npx -y dotenv-cli -- harperdb deploy . restart=rolling replicated=true"
12
13
  },
13
14
  "devDependencies": {
14
15
  "@harperfast/vite-plugin": "^0.0.1",
@@ -20,9 +21,9 @@
20
21
  "react": "^19.2.3",
21
22
  "react-dom": "^19.2.3",
22
23
  "typescript": "~5.9.3",
23
- "vite": "npm:rolldown-vite@7.2.5"
24
+ "vite": "npm:rolldown-vite@7.3.1"
24
25
  },
25
26
  "overrides": {
26
- "vite": "npm:rolldown-vite@7.2.5"
27
+ "vite": "npm:rolldown-vite@7.3.1"
27
28
  }
28
29
  }
@@ -1,4 +1,4 @@
1
- # <<projectName>>
1
+ # your-project-name-here
2
2
 
3
3
  Your new app is now deployed and running on Harper Fabric!
4
4
 
@@ -0,0 +1 @@
1
+ .env