generator-bitloops 0.1.0 → 0.3.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 +3 -3
- package/cli.mjs +40 -0
- package/package.json +8 -3
- package/setup/index.js +23 -5
- package/setup/templates/src.components.bitloops.Unsupported.tsx +39 -0
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
|
-
Nonetheless, you can use it independently to setup your next
|
|
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-bitloops",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Next.js with TypeScript, Tailwind, Storybook and Cypress generator by Bitloops",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bitloops S.A.",
|
|
7
7
|
"repository": {
|
|
@@ -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.mjs"
|
|
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', {
|
|
@@ -77,7 +85,7 @@ export default class extends Generator {
|
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
this.log("Installing Next.js...");
|
|
80
|
-
await new Promise((resolve, error) => {exec(`npx ${createNextAppCommand.join(' ')} && cd ${toKebabCase(this.options.project)} && npm install next@14 react@18 react-dom@18`).on('exit', (code) => {
|
|
88
|
+
await new Promise((resolve, error) => {exec(`npx ${createNextAppCommand.join(' ')} && cd ${toKebabCase(this.options.project)} && npm install next@14 react@18 react-dom@18 react-tooltip`).on('exit', (code) => {
|
|
81
89
|
this.destinationRoot(this.destinationPath(toKebabCase(this.options.project)));
|
|
82
90
|
resolve();
|
|
83
91
|
});});
|
|
@@ -103,17 +111,21 @@ 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
|
+
try {
|
|
119
|
+
fs.unlinkSync(this.destinationPath('next.config.ts'));
|
|
120
|
+
this.log(`Deleted next.config.ts`);
|
|
121
|
+
} catch (err) {
|
|
122
|
+
console.error('Error deleting next.config.ts:', err);
|
|
123
|
+
}
|
|
112
124
|
this.fs.copyTpl(
|
|
113
125
|
this.templatePath('next.config.js'),
|
|
114
126
|
this.destinationPath('next.config.js'),
|
|
115
|
-
);
|
|
116
|
-
this.log(`
|
|
127
|
+
);
|
|
128
|
+
this.log(`Created next.config.js instead`);
|
|
117
129
|
}
|
|
118
130
|
}
|
|
119
131
|
|
|
@@ -169,6 +181,12 @@ export default class extends Generator {
|
|
|
169
181
|
this.templatePath('globals.css'),
|
|
170
182
|
this.destinationPath('src/app/globals.css'),
|
|
171
183
|
);
|
|
184
|
+
|
|
185
|
+
this.log('Adding Bitloops support components...');
|
|
186
|
+
this.fs.copyTpl(
|
|
187
|
+
this.templatePath('src.components.bitloops.Unsupported.tsx'),
|
|
188
|
+
this.destinationPath('src/components/bitloops/Unsupported.tsx'),
|
|
189
|
+
);
|
|
172
190
|
}
|
|
173
191
|
}
|
|
174
192
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Tooltip } from 'react-tooltip';
|
|
2
|
+
import 'react-tooltip/dist/react-tooltip.css';
|
|
3
|
+
|
|
4
|
+
type UnsupportedType =
|
|
5
|
+
| 'VECTOR'
|
|
6
|
+
| 'STAR'
|
|
7
|
+
| 'ELLIPSE'
|
|
8
|
+
| 'LINE'
|
|
9
|
+
| 'REGULAR_POLYGON'
|
|
10
|
+
| 'SLICE'
|
|
11
|
+
| 'IMAGE';
|
|
12
|
+
|
|
13
|
+
export type UnsupportedElementProps = {
|
|
14
|
+
type: UnsupportedType;
|
|
15
|
+
elementClassName: string;
|
|
16
|
+
};
|
|
17
|
+
export function UnsupportedElement(props: UnsupportedElementProps) {
|
|
18
|
+
const { type, elementClassName } = props;
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
className={`${elementClassName} relative group border border-red-500 border-dashed`}
|
|
22
|
+
data-tooltip-id='tooltip'
|
|
23
|
+
data-tooltip-content={`Unsupported: ${type}`}
|
|
24
|
+
>
|
|
25
|
+
<Tooltip
|
|
26
|
+
id='tooltip'
|
|
27
|
+
place='top'
|
|
28
|
+
style={{
|
|
29
|
+
backgroundColor: 'black',
|
|
30
|
+
color: 'white',
|
|
31
|
+
padding: '8px',
|
|
32
|
+
borderRadius: '4px',
|
|
33
|
+
fontSize: '0.75rem',
|
|
34
|
+
whiteSpace: 'nowrap',
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|