@majordigital/create-acorn 1.0.1 → 1.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.
- package/bin/create-acorn.mjs +62 -8
- package/package.json +1 -1
package/bin/create-acorn.mjs
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import readline from 'node:readline';
|
|
4
4
|
import { argv, exit } from 'node:process';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
|
-
import { basename } from 'node:path';
|
|
6
|
+
import { basename, join } from 'node:path';
|
|
7
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
7
8
|
|
|
8
9
|
const CMS_CHOICES = [
|
|
9
10
|
{ key: 'prismic', label: 'Prismic' },
|
|
@@ -85,7 +86,7 @@ async function scaffoldNextApp() {
|
|
|
85
86
|
'.',
|
|
86
87
|
'--typescript',
|
|
87
88
|
'--tailwind',
|
|
88
|
-
'--eslint',
|
|
89
|
+
'--no-eslint',
|
|
89
90
|
'--app',
|
|
90
91
|
'--src-dir',
|
|
91
92
|
'--import-alias', '@/*',
|
|
@@ -94,6 +95,13 @@ async function scaffoldNextApp() {
|
|
|
94
95
|
console.log('');
|
|
95
96
|
console.log('Next.js project scaffolded successfully.');
|
|
96
97
|
console.log('');
|
|
98
|
+
|
|
99
|
+
console.log('Installing Biome for linting...');
|
|
100
|
+
await runCommand('npm', ['install', '--save-dev', '--save-exact', '@biomejs/biome']);
|
|
101
|
+
await runCommand('npx', ['@biomejs/biome', 'init']);
|
|
102
|
+
console.log('');
|
|
103
|
+
console.log('Biome configured successfully.');
|
|
104
|
+
console.log('');
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
async function setupPrismic() {
|
|
@@ -107,9 +115,15 @@ async function setupPrismic() {
|
|
|
107
115
|
const prefixed = defaultBase.startsWith('majordigital-') ? defaultBase : `majordigital-${defaultBase}`;
|
|
108
116
|
const suggested = nonInteractiveRepo || prefixed;
|
|
109
117
|
|
|
118
|
+
const hasExisting = await ask('Do you already have a Prismic repository? (y/n)', 'n');
|
|
119
|
+
const isExisting = hasExisting.toLowerCase() === 'y' || hasExisting.toLowerCase() === 'yes';
|
|
120
|
+
|
|
110
121
|
let repo = nonInteractiveRepo;
|
|
111
122
|
if (!repo) {
|
|
112
|
-
|
|
123
|
+
const prompt = isExisting
|
|
124
|
+
? 'Enter your existing Prismic repository name'
|
|
125
|
+
: 'Enter a name for your new Prismic repository';
|
|
126
|
+
repo = await ask(prompt, suggested);
|
|
113
127
|
}
|
|
114
128
|
|
|
115
129
|
if (!/^[a-z0-9-]+$/.test(repo)) {
|
|
@@ -117,15 +131,55 @@ async function setupPrismic() {
|
|
|
117
131
|
exit(1);
|
|
118
132
|
}
|
|
119
133
|
|
|
120
|
-
|
|
121
|
-
|
|
134
|
+
if (isExisting) {
|
|
135
|
+
console.log('');
|
|
136
|
+
console.log(`Connecting to existing Prismic repository: ${repo}`);
|
|
137
|
+
} else {
|
|
138
|
+
console.log('');
|
|
139
|
+
console.log(`Creating new Prismic repository: ${repo}`);
|
|
140
|
+
}
|
|
122
141
|
console.log('');
|
|
123
142
|
|
|
124
|
-
|
|
143
|
+
const initArgs = ['@slicemachine/init@latest', '--repository', repo];
|
|
144
|
+
if (isExisting) {
|
|
145
|
+
initArgs.push('--existing-repo');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
await runCommand('npx', initArgs);
|
|
149
|
+
|
|
150
|
+
// Ensure slicemachine script exists in package.json
|
|
151
|
+
const pkgPath = join(process.cwd(), 'package.json');
|
|
152
|
+
try {
|
|
153
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
154
|
+
if (!pkg.scripts) pkg.scripts = {};
|
|
155
|
+
if (!pkg.scripts.slicemachine) {
|
|
156
|
+
pkg.scripts.slicemachine = 'start-slicemachine';
|
|
157
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
158
|
+
console.log('');
|
|
159
|
+
console.log('Added "slicemachine" script to package.json.');
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
console.log('Warning: Could not update package.json with slicemachine script.');
|
|
163
|
+
}
|
|
125
164
|
|
|
126
165
|
console.log('');
|
|
127
|
-
console.log('Prismic
|
|
128
|
-
console.log('
|
|
166
|
+
console.log('=== Prismic Setup Complete ===');
|
|
167
|
+
console.log('');
|
|
168
|
+
console.log('NOTE: The default language is set to English - United States.');
|
|
169
|
+
console.log('Please update it to English - Europe (en-eu) in your Prismic project settings:');
|
|
170
|
+
console.log(` https://${repo}.prismic.io/settings/`);
|
|
171
|
+
console.log('');
|
|
172
|
+
console.log('=== Next Steps ===');
|
|
173
|
+
console.log('');
|
|
174
|
+
console.log(' 1. Start the Prismic Dev Tool (Slice Machine):');
|
|
175
|
+
console.log(' npm run slicemachine');
|
|
176
|
+
console.log('');
|
|
177
|
+
console.log(' 2. Create your custom types in Slice Machine (http://localhost:9999)');
|
|
178
|
+
console.log('');
|
|
179
|
+
console.log(' 3. Push your custom types to Prismic when ready');
|
|
180
|
+
console.log('');
|
|
181
|
+
console.log(' 4. Start your dev server:');
|
|
182
|
+
console.log(' npm run dev');
|
|
129
183
|
console.log('');
|
|
130
184
|
}
|
|
131
185
|
|
package/package.json
CHANGED