dappbooster 2.0.1 → 3.0.1

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 (59) hide show
  1. package/dist/app.d.ts +3 -0
  2. package/dist/app.js +49 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +6 -0
  5. package/dist/components/Ask.d.ts +11 -0
  6. package/dist/components/Ask.js +18 -0
  7. package/dist/components/Divider.d.ts +5 -0
  8. package/dist/components/Divider.js +4 -0
  9. package/dist/components/MainTitle.d.ts +3 -0
  10. package/dist/components/MainTitle.js +6 -0
  11. package/dist/components/Multiselect/MultiSelect.d.ts +33 -0
  12. package/dist/components/Multiselect/MultiSelect.js +68 -0
  13. package/dist/components/Multiselect/components/Checkbox.d.ts +6 -0
  14. package/dist/components/Multiselect/components/Checkbox.js +6 -0
  15. package/dist/components/Multiselect/components/Indicator.d.ts +6 -0
  16. package/dist/components/Multiselect/components/Indicator.js +6 -0
  17. package/dist/components/Multiselect/components/Item.d.ts +7 -0
  18. package/dist/components/Multiselect/components/Item.js +4 -0
  19. package/dist/components/Multiselect/index.d.ts +1 -0
  20. package/dist/components/Multiselect/index.js +1 -0
  21. package/dist/components/steps/CloneRepo/CloneRepo.d.ts +13 -0
  22. package/dist/components/steps/CloneRepo/CloneRepo.js +13 -0
  23. package/dist/components/steps/CloneRepo/Commands.d.ts +12 -0
  24. package/dist/components/steps/CloneRepo/Commands.js +29 -0
  25. package/dist/components/steps/FileCleanup.d.ts +18 -0
  26. package/dist/components/steps/FileCleanup.js +72 -0
  27. package/dist/components/steps/Install/CustomInstallation.d.ts +16 -0
  28. package/dist/components/steps/Install/CustomInstallation.js +31 -0
  29. package/dist/components/steps/Install/FullInstallation.d.ts +7 -0
  30. package/dist/components/steps/Install/FullInstallation.js +10 -0
  31. package/dist/components/steps/Install/Install.d.ts +12 -0
  32. package/dist/components/steps/Install/Install.js +29 -0
  33. package/dist/components/steps/Install/InstallAllPackages.d.ts +7 -0
  34. package/dist/components/steps/Install/InstallAllPackages.js +9 -0
  35. package/dist/components/steps/InstallationMode.d.ts +8 -0
  36. package/dist/components/steps/InstallationMode.js +28 -0
  37. package/dist/components/steps/OptionalPackages.d.ts +15 -0
  38. package/dist/components/steps/OptionalPackages.js +51 -0
  39. package/dist/components/steps/PostInstall.d.ts +16 -0
  40. package/dist/components/steps/PostInstall.js +79 -0
  41. package/dist/components/steps/ProjectName.d.ts +14 -0
  42. package/dist/components/steps/ProjectName.js +25 -0
  43. package/dist/constants/config.d.ts +4 -0
  44. package/dist/constants/config.js +18 -0
  45. package/dist/types/types.d.ts +10 -0
  46. package/dist/types/types.js +1 -0
  47. package/dist/utils/utils.d.ts +32 -0
  48. package/dist/utils/utils.js +47 -0
  49. package/package.json +30 -19
  50. package/readme.md +39 -0
  51. package/.nvmrc +0 -1
  52. package/.prettierrc +0 -7
  53. package/LICENSE +0 -21
  54. package/README.md +0 -36
  55. package/import/config.js +0 -17
  56. package/import/git.js +0 -56
  57. package/import/install.js +0 -199
  58. package/import/user-prompts.js +0 -145
  59. package/index.js +0 -33
package/import/install.js DELETED
@@ -1,199 +0,0 @@
1
- import { execSync } from 'node:child_process'
2
- import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
3
- import { join } from 'node:path'
4
- import chalk from 'chalk'
5
- import { defaultExecOptions, fileExecOptions, homeFolder, installPackageExecOptions } from './config.js'
6
-
7
- /**
8
- * @description Create the .env.local file
9
- */
10
- export function createEnvFile() {
11
- const envFilePath = join(process.cwd(), '.env.local')
12
- const exampleFilePath = join(process.cwd(), '.env.example')
13
-
14
- execSync(`cp ${exampleFilePath} ${envFilePath}`, defaultExecOptions)
15
- }
16
-
17
- /**
18
- * @description Install project packages, remove unwanted ones.
19
- */
20
- export function installPackages(
21
- demoSupport,
22
- subgraphSupport,
23
- typedocSupport,
24
- vocsSupport,
25
- huskySupport,
26
- ) {
27
- const subgraphPackages = !subgraphSupport
28
- ? [
29
- '@bootnodedev/db-subgraph',
30
- 'graphql graphql-request',
31
- '@graphql-codegen/cli',
32
- '@graphql-typed-document-node/core',
33
- ]
34
- : []
35
- const typedocPackages = !typedocSupport
36
- ? [
37
- 'typedoc',
38
- 'typedoc-github-theme',
39
- 'typedoc-plugin-inline-sources',
40
- 'typedoc-plugin-missing-exports',
41
- 'typedoc-plugin-rename-defaults',
42
- ]
43
- : []
44
- const vocsPackages = !vocsSupport ? ['vocs'] : []
45
- const huskyPackages = !huskySupport
46
- ? ['husky', 'lint-staged', '@commitlint/cli', '@commitlint/config-conventional']
47
- : []
48
-
49
- const packagesToRemove = [
50
- ...subgraphPackages,
51
- ...typedocPackages,
52
- ...vocsPackages,
53
- ...huskyPackages,
54
- ]
55
-
56
- console.log('\n---\n')
57
- console.log(`Installing packages...`)
58
-
59
- // Remove demo files
60
- if (!demoSupport) {
61
- demoFilesCleanup()
62
- }
63
-
64
- console.log('\n---\n')
65
-
66
- if (!packagesToRemove.length) {
67
- execSync('pnpm install --loglevel warn', installPackageExecOptions)
68
- console.log('\n---\n')
69
- } else {
70
- // pnpm remove will install the necessary packages while uninstalling the unwanted ones...
71
- execSync(`pnpm remove ${packagesToRemove.join(' ')} --loglevel warn`, installPackageExecOptions)
72
- // ... but it won't run the post-install script, so we run it manually
73
- execSync(`pnpm run postinstall`, installPackageExecOptions)
74
- console.log('\n---\n')
75
-
76
- // Remove package-related files and scripts
77
- packageFilesCleanup(subgraphSupport, typedocSupport, vocsSupport, huskySupport)
78
- }
79
-
80
- // Remove installer files
81
- installFilesCleanup()
82
- console.log('\n---\n')
83
- }
84
-
85
- /**
86
- * @description Removes demo-related folders and files
87
- */
88
- function demoFilesCleanup() {
89
- const absoluteHomeFolder = join(process.cwd(), homeFolder)
90
-
91
- console.log(`${chalk.bold.red('Removing')} demo list`)
92
-
93
- rmSync(absoluteHomeFolder, fileExecOptions)
94
-
95
- execSync(`mkdir -p ${absoluteHomeFolder}`, defaultExecOptions)
96
- execSync(
97
- `cp ${join(process.cwd(), '.install-files/home/index.tsx')} ${absoluteHomeFolder}`,
98
- defaultExecOptions,
99
- )
100
- }
101
-
102
- /**
103
- * @description Removes:
104
- * - Subgraphs folder
105
- * - Subgraph demos and references to them in the demos list
106
- */
107
- function subgraphCleanup() {
108
- const demoListFile = join(process.cwd(), `${homeFolder}/Examples/index.tsx`)
109
-
110
- // Remove the root subgraphs folder
111
- rmSync(join(process.cwd(), '/src/subgraphs'), fileExecOptions)
112
-
113
- // Only remove the subgraph demos if the user kept the demo list
114
- if (existsSync(demoListFile)) {
115
- // Remove the subgraph demos
116
- rmSync(join(process.cwd(), `${homeFolder}/Examples/demos/subgraphs`), fileExecOptions)
117
-
118
- // Remove the list...
119
- rmSync(demoListFile, { force: true })
120
-
121
- // ... and replace it by the list with no subgraph demos
122
- execSync(
123
- `cp ${join(process.cwd(), `.install-files/home/Examples/index.tsx`)} ${demoListFile}`,
124
- defaultExecOptions,
125
- )
126
- }
127
- }
128
-
129
- /**
130
- * @description Removes typedoc files
131
- */
132
- function typedocCleanup() {
133
- rmSync(join(process.cwd(), 'typedoc.json'), fileExecOptions)
134
- }
135
-
136
- /**
137
- * @description Removes Vocs files
138
- */
139
- function vocsCleanup() {
140
- rmSync(join(process.cwd(), 'vocs.config.ts'), fileExecOptions)
141
- rmSync(join(process.cwd(), 'docs'), fileExecOptions)
142
- }
143
-
144
- /**
145
- * @description Removes Husky files
146
- */
147
- function huskyCleanup() {
148
- rmSync(join(process.cwd(), '.lintstagedrc.mjs'), fileExecOptions)
149
- rmSync(join(process.cwd(), 'commitlint.config.js'), fileExecOptions)
150
- rmSync(join(process.cwd(), '.husky'), fileExecOptions)
151
- }
152
-
153
- /**
154
- * @description Removes the .install-files folder
155
- */
156
- function installFilesCleanup() {
157
- console.log(`${chalk.bold.red('Removing')} installer files`)
158
- rmSync(join(process.cwd(), '.install-files'), fileExecOptions)
159
- }
160
-
161
- /**
162
- * @description Cleans up the files associated with removed packages
163
- */
164
- function packageFilesCleanup(subgraphSupport, typedocSupport, vocsSupport, huskySupport) {
165
- const pkgPath = join(process.cwd(), 'package.json')
166
- const pkgJson = JSON.parse(readFileSync(pkgPath, 'utf8'))
167
-
168
- console.log(
169
- `${chalk.bold.red('Removing')} files and scripts associated with uninstalled packages`,
170
- )
171
-
172
- // Remove everything subgraph-related
173
- if (!subgraphSupport) {
174
- subgraphCleanup()
175
- pkgJson.scripts['subgraph-codegen'] = undefined
176
- }
177
-
178
- // Remove everything typedoc-related
179
- if (!typedocSupport) {
180
- typedocCleanup()
181
- pkgJson.scripts['typedoc:build'] = undefined
182
- }
183
-
184
- // Remove everything vocs-related
185
- if (!vocsSupport) {
186
- vocsCleanup()
187
- pkgJson.scripts['docs:build'] = undefined
188
- pkgJson.scripts['docs:dev'] = undefined
189
- pkgJson.scripts['docs:preview'] = undefined
190
- }
191
-
192
- // Remove everything husky-related
193
- if (!huskySupport) {
194
- huskyCleanup()
195
- pkgJson.scripts['prepare'] = undefined
196
- }
197
-
198
- writeFileSync(pkgPath, `${JSON.stringify(pkgJson, null, 2)}\n`)
199
- }
@@ -1,145 +0,0 @@
1
- import { join } from 'node:path'
2
- import readline from 'node:readline'
3
- import chalk from 'chalk'
4
- import { homeFolder } from './config.js'
5
-
6
- /**
7
- * @description Check if the project name is valid
8
- */
9
- export function checkProjectName(name) {
10
- const error = !name
11
- ? `
12
- #################################################
13
- # A directory name is mandatory. #
14
- # #
15
- # Letters (a–z, A–Z), numbers (0–9), #
16
- # hyphens (-), and underscores (_) are allowed. #
17
- #################################################`
18
- : !/^[a-zA-Z0-9-_]+$/.test(name)
19
- ? `
20
- #################################################
21
- # Invalid project name. #
22
- # #
23
- # Letters (a–z, A–Z), numbers (0–9), #
24
- # hyphens (-), and underscores (_) are allowed. #
25
- #################################################`
26
- : ''
27
-
28
- if (error) {
29
- console.error(`${chalk.red.bold(error.trim())}`)
30
- process.exit(1)
31
- } else {
32
- return name.replace(/[^a-zA-Z0-9-_]/g, '-')
33
- }
34
- }
35
-
36
- /**
37
- * @description Asks a question to the user
38
- */
39
- function askQuestion(query) {
40
- const rl = readline.createInterface({
41
- input: process.stdin,
42
- output: process.stdout,
43
- })
44
-
45
- return new Promise((resolve) => {
46
- rl.question(query, (answer) => {
47
- rl.close()
48
- resolve(answer)
49
- })
50
- })
51
- }
52
-
53
- /**
54
- * @description Asks the user for setup options
55
- * @returns {Promise<{demoSupport: boolean, subgraphSupport: boolean, typedocSupport: boolean, vocsSupport: boolean, commitHookPackagesSupport: boolean}>}
56
- */
57
- export async function installationSetup() {
58
- const demoSupport =
59
- (await askQuestion(`Keep the ${chalk.bold('home page demos')}? (Y/n) `)).toLowerCase() !== 'n'
60
-
61
- const subgraphSupport =
62
- (await askQuestion(`Keep ${chalk.bold('subgraph')} support? (Y/n) `)).toLowerCase() !== 'n'
63
-
64
- const typedocSupport =
65
- (
66
- await askQuestion(
67
- `Keep ${chalk.bold('Typedoc')} (converts TypeScript comments to HTML documentation) support? (Y/n) `,
68
- )
69
- ).toLowerCase() !== 'n'
70
-
71
- const vocsSupport =
72
- (
73
- await askQuestion(
74
- `Keep ${chalk.bold('Vocs')} (static markdown documentation generation) support? (Y/n) `,
75
- )
76
- ).toLowerCase() !== 'n'
77
-
78
- const huskySupport =
79
- (
80
- await askQuestion(
81
- `Keep ${chalk.bold('Husky')} (Git hooks) support? Note: removing this will also remove ${chalk.bold('lint-staged')} and ${chalk.bold('commitlint')} (Y/n) `,
82
- )
83
- ).toLowerCase() !== 'n'
84
-
85
- return {
86
- demoSupport,
87
- subgraphSupport,
88
- typedocSupport,
89
- vocsSupport,
90
- huskySupport,
91
- }
92
- }
93
-
94
- /**
95
- * @description Prints instructions for subgraph support
96
- */
97
- function subgraphInstructions() {
98
- console.log(
99
- `${chalk.yellow.bold('##################################################################################')}`,
100
- )
101
- console.log(
102
- `${chalk.yellow.bold('# WARNING: Your project support subgraphs, before you continue you MUST: #')}`,
103
- )
104
- console.log(
105
- `${chalk.yellow.bold('##################################################################################')}`,
106
- )
107
- console.log('')
108
- console.log(
109
- `1- Provide your own API key for the var ${chalk.bold('PUBLIC_SUBGRAPHS_API_KEY')} in ${chalk.italic('.env.local')}`,
110
- )
111
- console.log(
112
- ` You can get one at ${chalk.bold.underline('https://thegraph.com/studio/apikeys/')}`,
113
- )
114
- console.log(
115
- `2- Run ${chalk.bold('pnpm subgraph-codegen')} in your console from the project's folder`,
116
- )
117
- console.log('')
118
- console.log('Only after you followed these steps you may proceed.')
119
- console.log('\n---\n')
120
- }
121
-
122
- /**
123
- * @description Prints post-install instructions
124
- */
125
- export function postInstallInstructions(subgraphSupport, projectName) {
126
- console.log('To start development on your project:')
127
- console.log('')
128
- console.log('1- Move into the project directory')
129
- console.log(chalk.cyan(`$ cd ${projectName}`))
130
- console.log('')
131
- console.log('2- Start the development server')
132
- console.log(chalk.cyan('$ pnpm dev'))
133
- console.log('')
134
- console.log(
135
- `You can edit the home page in ${chalk.bold(`${join(process.cwd(), homeFolder)}/index.tsx`)}`,
136
- )
137
- console.log('\n---\n')
138
- console.log(`Check out ${chalk.bold('.env.local')} for more project configurations.`)
139
- console.log(`Check out the docs at ${chalk.bold.underline('https://docs.dappbooster.dev/')}`)
140
- console.log('\n---\n')
141
-
142
- if (subgraphSupport) {
143
- subgraphInstructions()
144
- }
145
- }
package/index.js DELETED
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { createEnvFile, installPackages } from './import/install.js'
4
- import { cloneRepo } from './import/git.js'
5
- import {
6
- checkProjectName,
7
- installationSetup,
8
- postInstallInstructions,
9
- } from './import/user-prompts.js'
10
-
11
- main().then(() => console.log('\nšŸ‘»\n'))
12
-
13
- /**
14
- * @description Main entry point
15
- */
16
- async function main() {
17
- // Check if the project name is valid
18
- const projectName = checkProjectName(process.argv[2])
19
-
20
- // Clone, create .env.local file
21
- cloneRepo(projectName)
22
- createEnvFile(projectName)
23
-
24
- // Ask setup questions
25
- const { demoSupport, subgraphSupport, typedocSupport, vocsSupport, huskySupport } =
26
- await installationSetup()
27
-
28
- // Install the required packages
29
- installPackages(demoSupport, subgraphSupport, typedocSupport, vocsSupport, huskySupport)
30
-
31
- // Tell the user what to do after installation is finished
32
- postInstallInstructions(subgraphSupport, projectName)
33
- }