@majordigital/create-acorn 1.0.7 → 1.0.9
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
CHANGED
|
@@ -97,8 +97,13 @@ async function scaffoldNextApp() {
|
|
|
97
97
|
console.log('Next.js project scaffolded successfully.');
|
|
98
98
|
console.log('');
|
|
99
99
|
|
|
100
|
-
//
|
|
100
|
+
// Add .npmrc with legacy-peer-deps so all npm installs (including Slice Machine) work with React 19
|
|
101
|
+
writeFileSync(join(process.cwd(), '.npmrc'), 'legacy-peer-deps=true\n');
|
|
102
|
+
|
|
103
|
+
// Remove configs generated by create-next-app that we replace
|
|
101
104
|
try { rmSync(join(process.cwd(), 'postcss.config.mjs')); } catch {}
|
|
105
|
+
try { rmSync(join(process.cwd(), 'next.config.ts')); } catch {}
|
|
106
|
+
try { rmSync(join(process.cwd(), 'next.config.js')); } catch {}
|
|
102
107
|
|
|
103
108
|
// Copy Acorn template files (src/, public/, config files) over the Next.js scaffold
|
|
104
109
|
console.log('Copying Acorn boilerplate...');
|
|
@@ -123,7 +128,7 @@ async function scaffoldNextApp() {
|
|
|
123
128
|
console.log('');
|
|
124
129
|
|
|
125
130
|
console.log('Installing Biome for linting...');
|
|
126
|
-
await runCommand('npm', ['install', '--save-dev', '--save-exact', '
|
|
131
|
+
await runCommand('npm', ['install', '--save-dev', '--save-exact', '@biomejs/biome']);
|
|
127
132
|
await runCommand('npx', ['@biomejs/biome', 'init']);
|
|
128
133
|
console.log('');
|
|
129
134
|
console.log('Biome configured successfully.');
|
|
@@ -204,6 +209,131 @@ async function setupPrismic() {
|
|
|
204
209
|
console.log('');
|
|
205
210
|
}
|
|
206
211
|
|
|
212
|
+
function generateReadme(projectName, cms) {
|
|
213
|
+
const title = projectName || 'Project Title';
|
|
214
|
+
|
|
215
|
+
const shared = `# ${title}
|
|
216
|
+
|
|
217
|
+
## Introduction 📖
|
|
218
|
+
|
|
219
|
+
## 📋 Prerequisites
|
|
220
|
+
|
|
221
|
+
- **Node.js**: v20.19.0 or higher
|
|
222
|
+
- **npm**: v10.8.2 or higher
|
|
223
|
+
|
|
224
|
+
## Running This Project 🚀
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
const prismic = `
|
|
228
|
+
This website is built using the [NextJS](https://nextjs.org/) framework, utilising [TypeScript](https://www.typescriptlang.org/) to strongly check types/props and provide helpful intelisense, and the utility-first CSS framework [Tailwind](https://tailwindcss.com/) as the styling library and the headless CMS [Prismic](https://prismic.io/).
|
|
229
|
+
|
|
230
|
+
To run this project, follow the instructions below:
|
|
231
|
+
|
|
232
|
+
1. Open the terminal, and navigate the root directory for this project.
|
|
233
|
+
2. Add in the environment variables in a \`.env\` file. More information found in the next section.
|
|
234
|
+
3. Run \`npm install\`, and wait for dependencies to install.
|
|
235
|
+
4. Run \`npm run dev\`, where a local instance of this website will be initiated e.g localhost:3000
|
|
236
|
+
5. Run \`npm run slicemachine\`, where a local instance of slicemachine will be initiated e.g localhost:9999
|
|
237
|
+
|
|
238
|
+
## Environment Variables 🔒
|
|
239
|
+
|
|
240
|
+
There are a few environmental variables required to run this project. As mentioned previously, each website setup requires it's own \`.env\` file within it's root directory.
|
|
241
|
+
|
|
242
|
+
To manage environment variables, follow these guidelines:
|
|
243
|
+
|
|
244
|
+
- Use \`.env\` for both local and production environments.
|
|
245
|
+
- The \`.env.development\` file will only be used for development builds.
|
|
246
|
+
- You can either:
|
|
247
|
+
- Include a \`.env.production\` file for production-specific configurations, **or**
|
|
248
|
+
- Use a single \`.env\` file that serves both local and production needs.
|
|
249
|
+
|
|
250
|
+
Make sure to configure your environment files appropriately based on your project's requirements.
|
|
251
|
+
|
|
252
|
+
The required variables are:
|
|
253
|
+
|
|
254
|
+
- **PRISMIC_ACCESS_TOKEN**: Found within the relevant project on our Prismic account
|
|
255
|
+
- **SITE_URL**: A full url path for the domain of this project, e.g. https://search-seven.netlify.app
|
|
256
|
+
`;
|
|
257
|
+
|
|
258
|
+
const storyblok = `
|
|
259
|
+
This website is built using the [NextJS](https://nextjs.org/) framework, utilising [TypeScript](https://www.typescriptlang.org/) to strongly check types/props and provide helpful intelisense, and the utility-first CSS framework [Tailwind](https://tailwindcss.com/) as the styling library and the headless CMS [Storyblok](https://www.storyblok.com/).
|
|
260
|
+
|
|
261
|
+
## 🛠️ Installation
|
|
262
|
+
|
|
263
|
+
1. **Install dependencies**
|
|
264
|
+
|
|
265
|
+
\`\`\`bash
|
|
266
|
+
npm install
|
|
267
|
+
\`\`\`
|
|
268
|
+
|
|
269
|
+
2. **Set up environment variables**
|
|
270
|
+
|
|
271
|
+
Create \`.env.local\` file in the root directory:
|
|
272
|
+
|
|
273
|
+
\`\`\`env
|
|
274
|
+
NEXT_PUBLIC_STORYBLOK_ACCESS_TOKEN=your_preview_token
|
|
275
|
+
STORYBLOK_SPACE_ID=your_space_id
|
|
276
|
+
NEXT_PUBLIC_STORYBLOK_TOKEN_VERSION=draft # or 'published' for production
|
|
277
|
+
\`\`\`
|
|
278
|
+
|
|
279
|
+
3. **Start the development server**
|
|
280
|
+
|
|
281
|
+
\`\`\`bash
|
|
282
|
+
npm run dev
|
|
283
|
+
\`\`\`
|
|
284
|
+
|
|
285
|
+
The site will be available at \`http://localhost:3000\`
|
|
286
|
+
|
|
287
|
+
4. **Run Storybook** (optional)
|
|
288
|
+
|
|
289
|
+
\`\`\`bash
|
|
290
|
+
npm run storybook
|
|
291
|
+
\`\`\`
|
|
292
|
+
|
|
293
|
+
Storybook will be available at \`http://localhost:6006\`
|
|
294
|
+
`;
|
|
295
|
+
|
|
296
|
+
const dato = `
|
|
297
|
+
This website is built using the [NextJS](https://nextjs.org/) framework, utilising [TypeScript](https://www.typescriptlang.org/) to strongly check types/props and provide helpful intelisense, and the utility-first CSS framework [Tailwind](https://tailwindcss.com/) as the styling library and the headless CMS [DatoCMS](https://www.datocms.com/).
|
|
298
|
+
|
|
299
|
+
## 🛠️ Installation
|
|
300
|
+
|
|
301
|
+
1. **Install dependencies**
|
|
302
|
+
|
|
303
|
+
\`\`\`bash
|
|
304
|
+
npm install
|
|
305
|
+
\`\`\`
|
|
306
|
+
|
|
307
|
+
2. **Set up environment variables**
|
|
308
|
+
|
|
309
|
+
Create \`.env.local\` file in the root directory:
|
|
310
|
+
|
|
311
|
+
\`\`\`env
|
|
312
|
+
DATOCMS_API_TOKEN=your_api_token
|
|
313
|
+
DATOCMS_PREVIEW_SECRET=your_preview_secret
|
|
314
|
+
SITE_URL=http://localhost:3000
|
|
315
|
+
\`\`\`
|
|
316
|
+
|
|
317
|
+
3. **Start the development server**
|
|
318
|
+
|
|
319
|
+
\`\`\`bash
|
|
320
|
+
npm run dev
|
|
321
|
+
\`\`\`
|
|
322
|
+
|
|
323
|
+
The site will be available at \`http://localhost:3000\`
|
|
324
|
+
`;
|
|
325
|
+
|
|
326
|
+
const cmsSection = cms === 'prismic' ? prismic : cms === 'storyblok' ? storyblok : dato;
|
|
327
|
+
|
|
328
|
+
const footer = `
|
|
329
|
+
## Contacts 🧑💻
|
|
330
|
+
|
|
331
|
+
The primary contact for this project is [Davs Howard](mailto:davs@majordigital.com).
|
|
332
|
+
`;
|
|
333
|
+
|
|
334
|
+
return shared + cmsSection + footer;
|
|
335
|
+
}
|
|
336
|
+
|
|
207
337
|
async function main() {
|
|
208
338
|
printHeader();
|
|
209
339
|
let selection = parseNonInteractiveArg();
|
|
@@ -234,6 +364,38 @@ async function main() {
|
|
|
234
364
|
console.log('This run only confirms selection for non-Prismic options.');
|
|
235
365
|
console.log('');
|
|
236
366
|
}
|
|
367
|
+
|
|
368
|
+
// Generate .env.example
|
|
369
|
+
const envExamples = {
|
|
370
|
+
prismic: `PRISMIC_ACCESS_TOKEN=
|
|
371
|
+
SITE_URL=
|
|
372
|
+
`,
|
|
373
|
+
storyblok: `STORYBLOK_SPACE_ID=
|
|
374
|
+
STORYBLOK_PREVIEW_TOKEN=
|
|
375
|
+
STORYBLOK_PERSONAL_ACCESS_TOKEN=
|
|
376
|
+
NEXT_PUBLIC_STORYBLOK_PUBLIC_TOKEN=
|
|
377
|
+
NEXT_PUBLIC_STORYBLOK_TOKEN_VERSION="draft"
|
|
378
|
+
STORYBLOK_WEBHOOK_TOKEN=
|
|
379
|
+
INTERNAL_PREVIEW_SECRET=
|
|
380
|
+
INTERNAL_PREVIEW_API_KEY=
|
|
381
|
+
NEXT_PUBLIC_SITE_URL=
|
|
382
|
+
NEXT_PUBLIC_HUBSPOT_PORTAL_ID=
|
|
383
|
+
`,
|
|
384
|
+
dato: `DATOCMS_API_TOKEN=
|
|
385
|
+
DATOCMS_PREVIEW_SECRET=
|
|
386
|
+
SITE_URL=
|
|
387
|
+
`,
|
|
388
|
+
};
|
|
389
|
+
writeFileSync(join(process.cwd(), '.env.example'), envExamples[selection.key]);
|
|
390
|
+
console.log('.env.example generated.');
|
|
391
|
+
console.log('');
|
|
392
|
+
|
|
393
|
+
// Generate project README
|
|
394
|
+
const projectName = basename(process.cwd());
|
|
395
|
+
const readme = generateReadme(projectName, selection.key);
|
|
396
|
+
writeFileSync(join(process.cwd(), 'README.md'), readme);
|
|
397
|
+
console.log('README.md generated.');
|
|
398
|
+
console.log('');
|
|
237
399
|
}
|
|
238
400
|
|
|
239
401
|
main().catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NextConfig } from 'next';
|
|
2
|
+
import bundleAnalyzer from '@next/bundle-analyzer';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const withBundleAnalyzer = bundleAnalyzer({
|
|
5
|
+
enabled: process.env.ANALYZE === 'true',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const baseConfig: NextConfig = {
|
|
4
9
|
poweredByHeader: false,
|
|
5
10
|
reactStrictMode: true,
|
|
6
11
|
trailingSlash: false,
|
|
@@ -22,7 +27,7 @@ const baseConfig = {
|
|
|
22
27
|
|
|
23
28
|
return config;
|
|
24
29
|
},
|
|
25
|
-
|
|
30
|
+
|
|
26
31
|
images: {
|
|
27
32
|
remotePatterns: [
|
|
28
33
|
{
|
|
@@ -41,8 +46,4 @@ const baseConfig = {
|
|
|
41
46
|
},
|
|
42
47
|
};
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
enabled: process.env.ANALYZE === 'true',
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
module.exports = withBundleAnalyzer(baseConfig);
|
|
49
|
+
export default withBundleAnalyzer(baseConfig);
|