@plutocms/create-pluto 0.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.
- package/.editorconfig +12 -0
- package/.gitattributes +2 -0
- package/.prettierrc +9 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +8 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/bin/cli.mjs +7 -0
- package/bun.lock +57 -0
- package/package.json +45 -0
- package/src/index.ts +163 -0
- package/tsconfig.json +28 -0
- package/tsdown.config.ts +5 -0
package/.editorconfig
ADDED
package/.gitattributes
ADDED
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Victor Ribeiro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/bin/cli.mjs
ADDED
package/bun.lock
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lockfileVersion": 1,
|
|
3
|
+
"configVersion": 0,
|
|
4
|
+
"workspaces": {
|
|
5
|
+
"": {
|
|
6
|
+
"name": "create-pluto",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@clack/prompts": "^0.11.0",
|
|
9
|
+
"giget": "^2.0.0",
|
|
10
|
+
"jiti": "^2.6.1",
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"prettier": "^3.6.2",
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"typescript": "^5",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
"packages": {
|
|
21
|
+
"@clack/core": ["@clack/core@0.5.0", "", { "dependencies": { "picocolors": "^1.0.0", "sisteransi": "^1.0.5" } }, "sha512-p3y0FIOwaYRUPRcMO7+dlmLh8PSRcrjuTndsiA0WAFbWES0mLZlrjVoBRZ9DzkPFJZG6KGkJmoEAY0ZcVWTkow=="],
|
|
22
|
+
|
|
23
|
+
"@clack/prompts": ["@clack/prompts@0.11.0", "", { "dependencies": { "@clack/core": "0.5.0", "picocolors": "^1.0.0", "sisteransi": "^1.0.5" } }, "sha512-pMN5FcrEw9hUkZA4f+zLlzivQSeQf5dRGJjSUbvVYDLvpKCdQx5OaknvKzgbtXOizhP+SJJJjqEbOe55uKKfAw=="],
|
|
24
|
+
|
|
25
|
+
"citty": ["citty@0.1.6", "", { "dependencies": { "consola": "^3.2.3" } }, "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ=="],
|
|
26
|
+
|
|
27
|
+
"confbox": ["confbox@0.2.2", "", {}, "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ=="],
|
|
28
|
+
|
|
29
|
+
"consola": ["consola@3.4.2", "", {}, "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA=="],
|
|
30
|
+
|
|
31
|
+
"defu": ["defu@6.1.4", "", {}, "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg=="],
|
|
32
|
+
|
|
33
|
+
"exsolve": ["exsolve@1.0.7", "", {}, "sha512-VO5fQUzZtI6C+vx4w/4BWJpg3s/5l+6pRQEHzFRM8WFi4XffSP1Z+4qi7GbjWbvRQEbdIco5mIMq+zX4rPuLrw=="],
|
|
34
|
+
|
|
35
|
+
"giget": ["giget@2.0.0", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.0", "defu": "^6.1.4", "node-fetch-native": "^1.6.6", "nypm": "^0.6.0", "pathe": "^2.0.3" }, "bin": { "giget": "dist/cli.mjs" } }, "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA=="],
|
|
36
|
+
|
|
37
|
+
"jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="],
|
|
38
|
+
|
|
39
|
+
"node-fetch-native": ["node-fetch-native@1.6.7", "", {}, "sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q=="],
|
|
40
|
+
|
|
41
|
+
"nypm": ["nypm@0.6.2", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.2", "pathe": "^2.0.3", "pkg-types": "^2.3.0", "tinyexec": "^1.0.1" }, "bin": { "nypm": "dist/cli.mjs" } }, "sha512-7eM+hpOtrKrBDCh7Ypu2lJ9Z7PNZBdi/8AT3AX8xoCj43BBVHD0hPSTEvMtkMpfs8FCqBGhxB+uToIQimA111g=="],
|
|
42
|
+
|
|
43
|
+
"pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
|
44
|
+
|
|
45
|
+
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
|
46
|
+
|
|
47
|
+
"pkg-types": ["pkg-types@2.3.0", "", { "dependencies": { "confbox": "^0.2.2", "exsolve": "^1.0.7", "pathe": "^2.0.3" } }, "sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig=="],
|
|
48
|
+
|
|
49
|
+
"prettier": ["prettier@3.6.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],
|
|
50
|
+
|
|
51
|
+
"sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="],
|
|
52
|
+
|
|
53
|
+
"tinyexec": ["tinyexec@1.0.2", "", {}, "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg=="],
|
|
54
|
+
|
|
55
|
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
56
|
+
}
|
|
57
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plutocms/create-pluto",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"module": "./bin/cli.mjs",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-pluto": "bin/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"setup": "node src/index.ts"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"prettier": "^3.6.2"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"typescript": "^5"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@clack/prompts": "^0.11.0",
|
|
20
|
+
"giget": "^2.0.0",
|
|
21
|
+
"jiti": "^2.6.1"
|
|
22
|
+
},
|
|
23
|
+
"description": "CLI Wizard for creating a Pluto App",
|
|
24
|
+
"main": "./src/index.ts",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/plutocms/pluto.git"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"pluto",
|
|
31
|
+
"plutocms",
|
|
32
|
+
"nuxt",
|
|
33
|
+
"vue",
|
|
34
|
+
"cms",
|
|
35
|
+
"wordpress",
|
|
36
|
+
"headless",
|
|
37
|
+
"cms"
|
|
38
|
+
],
|
|
39
|
+
"author": "https://github.com/ojvribeiro",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/plutocms/pluto/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/plutocms/pluto#readme"
|
|
45
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
text,
|
|
3
|
+
select,
|
|
4
|
+
spinner,
|
|
5
|
+
log,
|
|
6
|
+
isCancel,
|
|
7
|
+
cancel,
|
|
8
|
+
confirm,
|
|
9
|
+
} from '@clack/prompts'
|
|
10
|
+
import { downloadTemplate } from 'giget'
|
|
11
|
+
import fs from 'fs'
|
|
12
|
+
|
|
13
|
+
const cwd = process.cwd()
|
|
14
|
+
|
|
15
|
+
// Where you want to download the template
|
|
16
|
+
const templateDir = await text({
|
|
17
|
+
message: 'Where do you want to create your Pluto project?',
|
|
18
|
+
placeholder: './my-pluto-project',
|
|
19
|
+
defaultValue: 'my-pluto-project',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
if (isCancel(templateDir)) {
|
|
23
|
+
cancel('Operation cancelled.')
|
|
24
|
+
|
|
25
|
+
process.exit(0)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const templatePath = `${cwd}/${templateDir}`
|
|
29
|
+
|
|
30
|
+
if (!fs.existsSync(templatePath)) {
|
|
31
|
+
fs.mkdirSync(templatePath, { recursive: true })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Ask for website title
|
|
35
|
+
const websiteTitle = await text({
|
|
36
|
+
message: 'Website title:',
|
|
37
|
+
placeholder: 'My Awesome Website',
|
|
38
|
+
defaultValue: 'My Awesome Website',
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
if (isCancel(websiteTitle)) {
|
|
42
|
+
cancel('Operation cancelled.')
|
|
43
|
+
|
|
44
|
+
process.exit(0)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Ask for database provider
|
|
48
|
+
const databaseProvider = await select({
|
|
49
|
+
message: 'Pick a database provider.',
|
|
50
|
+
options: [
|
|
51
|
+
{ value: 'supabase', label: 'Supabase' },
|
|
52
|
+
{ value: 'mysql', label: 'MySQL' },
|
|
53
|
+
],
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
if (isCancel(databaseProvider)) {
|
|
57
|
+
cancel('Operation cancelled.')
|
|
58
|
+
|
|
59
|
+
process.exit(0)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let supabaseUrl: string | symbol | undefined
|
|
63
|
+
let supabaseKey: string | symbol | undefined
|
|
64
|
+
|
|
65
|
+
if (databaseProvider === 'supabase') {
|
|
66
|
+
await setupSupabase()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function setupSupabase() {
|
|
70
|
+
while (!supabaseUrl) {
|
|
71
|
+
supabaseUrl = await text({
|
|
72
|
+
message: 'Type/Paste your Supabase URL:',
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
if (!supabaseUrl || typeof supabaseUrl !== 'string') {
|
|
76
|
+
log.error('Supabase URL is required.')
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
while (!supabaseKey) {
|
|
81
|
+
supabaseKey = await text({
|
|
82
|
+
message: 'Type/Paste your Supabase Key:',
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
if (!supabaseKey || typeof supabaseKey !== 'string') {
|
|
86
|
+
log.error('Supabase Key is required.')
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const s = spinner()
|
|
92
|
+
|
|
93
|
+
// Check if nuxt.config.ts exists
|
|
94
|
+
if (fs.existsSync(`${cwd}/nuxt.config.ts`)) {
|
|
95
|
+
const shouldContinue = await confirm({
|
|
96
|
+
message:
|
|
97
|
+
'Nuxt project detected. Do you want to add Pluto environment variables?',
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
if (!shouldContinue) {
|
|
101
|
+
process.exit(0)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
log.success('Configuration successful! Proceeding with setup...')
|
|
106
|
+
|
|
107
|
+
s.start('Downloading Pluto template...')
|
|
108
|
+
|
|
109
|
+
const { source } = await downloadTemplate(
|
|
110
|
+
'gh:plutocms/pluto-minimal-template',
|
|
111
|
+
{
|
|
112
|
+
dir: templatePath,
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
log.info(`Template downloaded from ${source}`)
|
|
117
|
+
|
|
118
|
+
// Write to .env file if exists or create a new one
|
|
119
|
+
const envPath = `${cwd}/${templateDir}/.env`
|
|
120
|
+
const envVars: Record<string, string> = {
|
|
121
|
+
PLUTO_WEBSITE_TITLE: websiteTitle?.toString() ?? '',
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (databaseProvider === 'supabase') {
|
|
125
|
+
envVars.SUPABASE_PROJECT_ID = supabaseUrl
|
|
126
|
+
? (supabaseUrl.toString().split('//')[1]?.split('.')[0] ?? '')
|
|
127
|
+
: ''
|
|
128
|
+
envVars.SUPABASE_URL = supabaseUrl?.toString() ?? ''
|
|
129
|
+
envVars.SUPABASE_KEY = supabaseKey?.toString() ?? ''
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
let envContent = ''
|
|
134
|
+
if (fs.existsSync(envPath)) {
|
|
135
|
+
envContent = fs.readFileSync(envPath, 'utf-8')
|
|
136
|
+
|
|
137
|
+
Object.entries(envVars).forEach(([key, value]) => {
|
|
138
|
+
const regex = new RegExp(`^${key}=.*$`, 'm')
|
|
139
|
+
if (regex.test(envContent)) {
|
|
140
|
+
envContent = envContent.replace(regex, `${key}="${value}"`)
|
|
141
|
+
} else {
|
|
142
|
+
envContent += `\n${key}="${value}"`
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
} else {
|
|
146
|
+
envContent = '# Pluto Configurations\n'
|
|
147
|
+
Object.entries(envVars).forEach(([key, value]) => {
|
|
148
|
+
envContent += `${key}="${value}"\n`
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
fs.writeFileSync(envPath, envContent.trim() + '\n')
|
|
153
|
+
} catch (error) {
|
|
154
|
+
log.error(`Failed to write to .env file: ${error}`)
|
|
155
|
+
|
|
156
|
+
process.exit(1)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
s.stop('All done!')
|
|
160
|
+
|
|
161
|
+
log.success('Setup complete! 🎉')
|
|
162
|
+
|
|
163
|
+
log.info(`Nuxt project created in: ${templateDir}`)
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Environment setup & latest features
|
|
4
|
+
"lib": ["ESNext"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "nodenext",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
|
|
10
|
+
// Bundler mode
|
|
11
|
+
"moduleResolution": "nodenext",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
|
|
16
|
+
// Best practices
|
|
17
|
+
"strict": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
|
20
|
+
"noUncheckedIndexedAccess": true,
|
|
21
|
+
"noImplicitOverride": true,
|
|
22
|
+
|
|
23
|
+
// Some stricter flags (disabled by default)
|
|
24
|
+
"noUnusedLocals": false,
|
|
25
|
+
"noUnusedParameters": false,
|
|
26
|
+
"noPropertyAccessFromIndexSignature": false
|
|
27
|
+
}
|
|
28
|
+
}
|