generator-bitloops 0.3.21 → 0.3.23
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/app/index.js +1 -0
- package/package.json +1 -1
- package/setup/index.js +66 -20
package/app/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export default class extends Generator {
|
|
|
11
11
|
this.option('tailwind'); // This method adds support for a `--tailwind` flag
|
|
12
12
|
this.option('storybook'); // This method adds support for a `--storybook` flag
|
|
13
13
|
this.option('cypress'); // This method adds support for a `--cypress` flag
|
|
14
|
+
this.option('primitives'); // This method adds support for a `--primitives` flag
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
message() {
|
package/package.json
CHANGED
package/setup/index.js
CHANGED
|
@@ -105,6 +105,12 @@ export default class extends Generator {
|
|
|
105
105
|
default: false,
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
+
this.option('primitives', {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
description: 'Add primitives support',
|
|
111
|
+
default: false,
|
|
112
|
+
});
|
|
113
|
+
|
|
108
114
|
this.installNextJS = async function () {
|
|
109
115
|
// Clone Next.js template with Tailwind if specified, using the project name
|
|
110
116
|
const createNextAppCommand = ['-y', 'create-next-app@15.3.3'];
|
|
@@ -203,6 +209,36 @@ export default class extends Generator {
|
|
|
203
209
|
}
|
|
204
210
|
};
|
|
205
211
|
|
|
212
|
+
this.installPrimitives = function () {
|
|
213
|
+
// Conditionally add Primitives
|
|
214
|
+
if (this.options.primitives) {
|
|
215
|
+
this.log('Installing Primitives...');
|
|
216
|
+
|
|
217
|
+
const platformNextIndexPath = `${PLATFORM_NEXT_SRC_FOLDER}/index.ts`;
|
|
218
|
+
deleteFileIfExists(this.destinationPath(platformNextIndexPath));
|
|
219
|
+
this.fs.copyTpl(
|
|
220
|
+
this.templatePath(platformNextIndexPath),
|
|
221
|
+
this.destinationPath(platformNextIndexPath)
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
const platformNextImgPath = `${PLATFORM_NEXT_SRC_FOLDER}/Img.tsx`;
|
|
225
|
+
deleteFileIfExists(this.destinationPath(platformNextImgPath));
|
|
226
|
+
this.fs.copyTpl(
|
|
227
|
+
this.templatePath(platformNextImgPath),
|
|
228
|
+
this.destinationPath(platformNextImgPath)
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const platformNextTypesPath = `${PLATFORM_NEXT_SRC_FOLDER}/types.ts`;
|
|
232
|
+
deleteFileIfExists(this.destinationPath(platformNextTypesPath));
|
|
233
|
+
this.fs.copyTpl(
|
|
234
|
+
this.templatePath(platformNextTypesPath),
|
|
235
|
+
this.destinationPath(platformNextTypesPath)
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
this.log('Primitives installed!');
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
206
242
|
this.patchFiles = async function () {
|
|
207
243
|
// Conditionally initialize Storybook
|
|
208
244
|
if (this.options.storybook) {
|
|
@@ -255,26 +291,35 @@ export default class extends Generator {
|
|
|
255
291
|
this.destinationPath('src/app/globals.css')
|
|
256
292
|
);
|
|
257
293
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
this.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
294
|
+
if (this.options.typescript) {
|
|
295
|
+
this.log('Updating tsconfig.json paths...');
|
|
296
|
+
const tsconfigPath = this.destinationPath('tsconfig.json');
|
|
297
|
+
if (this.fs.exists(tsconfigPath)) {
|
|
298
|
+
const tsconfigContent = this.fs.read(tsconfigPath);
|
|
299
|
+
const tsconfig = JSON.parse(tsconfigContent);
|
|
300
|
+
|
|
301
|
+
// Initialize compilerOptions if it doesn't exist
|
|
302
|
+
if (!tsconfig.compilerOptions) {
|
|
303
|
+
tsconfig.compilerOptions = {};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Initialize paths if it doesn't exist
|
|
307
|
+
if (!tsconfig.compilerOptions.paths) {
|
|
308
|
+
tsconfig.compilerOptions.paths = {};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Add or merge the path aliases
|
|
312
|
+
tsconfig.compilerOptions.paths = {
|
|
313
|
+
...tsconfig.compilerOptions.paths,
|
|
314
|
+
"@/primitives": ["./platform-next/src"],
|
|
315
|
+
"@/assets": ["./src/assets"]
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
deleteFileIfExists(tsconfigPath);
|
|
319
|
+
this.fs.write(tsconfigPath, JSON.stringify(tsconfig, null, 2) + '\n');
|
|
320
|
+
this.log('tsconfig.json paths updated!');
|
|
321
|
+
}
|
|
322
|
+
}
|
|
278
323
|
|
|
279
324
|
if (this.options.bitloops) {
|
|
280
325
|
this.log('Adding Bitloops support components...');
|
|
@@ -361,6 +406,7 @@ export default class extends Generator {
|
|
|
361
406
|
await this.installNextJS();
|
|
362
407
|
this.installStorybook();
|
|
363
408
|
this.installCypress();
|
|
409
|
+
this.installPrimitives();
|
|
364
410
|
await this.patchFiles();
|
|
365
411
|
if (this.options.git) {
|
|
366
412
|
await this.commitChanges();
|