generator-bitloops 0.1.0 → 0.2.0
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/README.md +2 -2
- package/cli.mjs +40 -0
- package/package.json +7 -2
- package/setup/index.js +10 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# generator-bitloops
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Bitloops Generator is used by the Bitloops Platform to setup your Bitloops projects.
|
|
4
4
|
|
|
5
5
|
Nonetheless, you can use it independently to setup your next next.js project with TypeScript, Tailwind, Storybook and Cypress all ready to go!
|
|
6
6
|
|
|
7
7
|
## How to run it
|
|
8
8
|
|
|
9
|
-
`npx
|
|
9
|
+
`npx generator-bitloops setup --project="Your Project Name" --nextjs --typescript --tailwind --storybook --cypress`
|
package/cli.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createEnv } from 'yeoman-environment';
|
|
4
|
+
import npm from './package.json' assert { type: 'json' };
|
|
5
|
+
|
|
6
|
+
console.log(`generator-bitloops v${npm.version}`);
|
|
7
|
+
|
|
8
|
+
// Capture the subgenerator and additional arguments
|
|
9
|
+
const [, , subgenerator, ...args] = process.argv;
|
|
10
|
+
|
|
11
|
+
if (!subgenerator) {
|
|
12
|
+
console.error('Please specify a subgenerator (e.g., "setup" or "init")');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Initialize Yeoman environment
|
|
17
|
+
const env = createEnv();
|
|
18
|
+
|
|
19
|
+
(async () => {
|
|
20
|
+
// Dynamically import the subgenerator path
|
|
21
|
+
const generatorPath = await import(`./${subgenerator}/index.js`);
|
|
22
|
+
|
|
23
|
+
// Register your generator
|
|
24
|
+
env.register(generatorPath.default, `bitloops:${subgenerator}`);
|
|
25
|
+
|
|
26
|
+
// Convert arguments into a format suitable for Yeoman
|
|
27
|
+
const options = args.reduce((acc, arg) => {
|
|
28
|
+
const [key, value] = arg.split('=');
|
|
29
|
+
acc[key.replace('--', '')] = value || true;
|
|
30
|
+
return acc;
|
|
31
|
+
}, {});
|
|
32
|
+
|
|
33
|
+
// Run the generator with the specified subgenerator and options
|
|
34
|
+
env.run(`bitloops:${subgenerator}`, options, (err) => {
|
|
35
|
+
if (err) {
|
|
36
|
+
console.error('Error running generator:', err);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-bitloops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Bitloops Yeoman generator",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bitloops S.A.",
|
|
@@ -9,9 +9,13 @@
|
|
|
9
9
|
"url": "https://github.com/bitloops/generator-bitloops"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
|
+
"bin": {
|
|
13
|
+
"bitloops-generator": "./cli.mjs"
|
|
14
|
+
},
|
|
12
15
|
"files": [
|
|
13
16
|
"app",
|
|
14
|
-
"setup"
|
|
17
|
+
"setup",
|
|
18
|
+
"cli.js"
|
|
15
19
|
],
|
|
16
20
|
"keywords": [
|
|
17
21
|
"bitloops",
|
|
@@ -23,6 +27,7 @@
|
|
|
23
27
|
"yeoman-generator"
|
|
24
28
|
],
|
|
25
29
|
"dependencies": {
|
|
30
|
+
"yeoman-environment": "^4.4.3",
|
|
26
31
|
"yeoman-generator": "^7.3.3"
|
|
27
32
|
}
|
|
28
33
|
}
|
package/setup/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { exec } from 'child_process';
|
|
3
3
|
import Generator from 'yeoman-generator';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
// Convert `import.meta.url` to a path
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
4
11
|
|
|
5
12
|
function toKebabCase(str) {
|
|
6
13
|
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase().replace(/\s+/g, '-');
|
|
@@ -9,6 +16,7 @@ function toKebabCase(str) {
|
|
|
9
16
|
export default class extends Generator {
|
|
10
17
|
constructor(args, opts) {
|
|
11
18
|
super(args, opts);
|
|
19
|
+
this.sourceRoot(path.join(__dirname, 'templates'));
|
|
12
20
|
|
|
13
21
|
// Define options
|
|
14
22
|
this.option('project', {
|
|
@@ -103,12 +111,13 @@ export default class extends Generator {
|
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
this.patchFiles = async function() {
|
|
106
|
-
// await new Promise((resolve, reject) => this.fs.commit((err) => (err ? reject(err) : resolve())));
|
|
107
114
|
if (this.options.storybook) {
|
|
108
115
|
if (this.options.typescript) {
|
|
109
116
|
this.log('Replace Next.js\' TypeScript configuration file with JS...');
|
|
110
117
|
// Remove TypeScript configuration files given they require Next.js 15
|
|
111
118
|
fs.unlinkSync(this.destinationPath('next.config.ts'));
|
|
119
|
+
console.log('Template Path:', this.templatePath('next.config.js'));
|
|
120
|
+
console.log('Destination Path:', this.destinationPath('next.config.js'));
|
|
112
121
|
this.fs.copyTpl(
|
|
113
122
|
this.templatePath('next.config.js'),
|
|
114
123
|
this.destinationPath('next.config.js'),
|