@fastkit/plugboy 0.2.7 → 1.0.0-next.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 +355 -0
- package/dist/cli.d.mts +5 -0
- package/dist/cli.mjs +33 -128
- package/dist/cli.mjs.map +1 -1
- package/dist/combine-rules-CWp-M491.mjs +66 -0
- package/dist/combine-rules-CWp-M491.mjs.map +1 -0
- package/dist/dependencies/bundle-require.d.mts +1 -0
- package/dist/dependencies/bundle-require.mjs +3 -3
- package/dist/dependencies/cac.d.mts +1 -0
- package/dist/dependencies/cac.mjs +3 -3
- package/dist/dependencies/glob.d.mts +1 -0
- package/dist/dependencies/glob.mjs +3 -3
- package/dist/dependencies/inquirer.d.mts +1 -0
- package/dist/dependencies/inquirer.mjs +3 -3
- package/dist/dependencies/pkg-types.d.mts +1 -0
- package/dist/dependencies/pkg-types.mjs +3 -3
- package/dist/dependencies/sort-package-json.d.mts +2 -0
- package/dist/dependencies/sort-package-json.mjs +5 -4
- package/dist/dependencies/sort-package-json.mjs.map +1 -1
- package/dist/dependencies/tsdown.d.mts +1 -0
- package/dist/dependencies/tsdown.mjs +3 -0
- package/dist/optimize-layer-CK8NR_VC.mjs +58 -0
- package/dist/optimize-layer-CK8NR_VC.mjs.map +1 -0
- package/dist/optimize-media-Bxy27Cj7.mjs +86 -0
- package/dist/optimize-media-Bxy27Cj7.mjs.map +1 -0
- package/dist/plugboy.d.mts +6284 -0
- package/dist/plugboy.mjs +3 -103
- package/dist/runtime-utils.d.mts +28 -0
- package/dist/runtime-utils.mjs +94 -0
- package/dist/runtime-utils.mjs.map +1 -0
- package/dist/workspace-BqcryYAT.mjs +1391 -0
- package/dist/workspace-BqcryYAT.mjs.map +1 -0
- package/env.d.ts +0 -18
- package/package.json +21 -17
- package/dist/chunk-MN572VU2.mjs +0 -1616
- package/dist/chunk-MN572VU2.mjs.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/combine-rules-2CRG6D4B.mjs +0 -69
- package/dist/combine-rules-2CRG6D4B.mjs.map +0 -1
- package/dist/dependencies/bundle-require.d.ts +0 -7
- package/dist/dependencies/bundle-require.mjs.map +0 -1
- package/dist/dependencies/cac.d.ts +0 -1
- package/dist/dependencies/cac.mjs.map +0 -1
- package/dist/dependencies/esbuild.d.ts +0 -1
- package/dist/dependencies/esbuild.mjs +0 -3
- package/dist/dependencies/esbuild.mjs.map +0 -1
- package/dist/dependencies/glob.d.ts +0 -1
- package/dist/dependencies/glob.mjs.map +0 -1
- package/dist/dependencies/inquirer.d.ts +0 -1
- package/dist/dependencies/inquirer.mjs.map +0 -1
- package/dist/dependencies/pkg-types.d.ts +0 -1
- package/dist/dependencies/pkg-types.mjs.map +0 -1
- package/dist/dependencies/sort-package-json.d.ts +0 -2
- package/dist/dependencies/tsup.d.ts +0 -1
- package/dist/dependencies/tsup.mjs +0 -3
- package/dist/dependencies/tsup.mjs.map +0 -1
- package/dist/optimize-layer-Q35C25P4.mjs +0 -61
- package/dist/optimize-layer-Q35C25P4.mjs.map +0 -1
- package/dist/optimize-media-ZZWDHLLV.mjs +0 -99
- package/dist/optimize-media-ZZWDHLLV.mjs.map +0 -1
- package/dist/plugboy.d.ts +0 -777
- package/dist/plugboy.mjs.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
|
|
2
|
+
# @fastkit/plugboy
|
|
3
|
+
|
|
4
|
+
🌐 English | [日本語](https://github.com/dadajam4/fastkit/blob/main/packages/plugboy/README-ja.md)
|
|
5
|
+
|
|
6
|
+
A monorepo-compatible module bundler and project management tool. Provides a high-speed build system based on tsdown, and other tools.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **High-Speed Build**: Ultra-fast bundling based on tsdown
|
|
11
|
+
- **Monorepo Support**: Integrated management of multi-package projects
|
|
12
|
+
- **Full TypeScript Support**: Automatic type definition generation and optimization
|
|
13
|
+
- **Plugin System**: Extensible architecture
|
|
14
|
+
- **CSS Integration**: Sass, Vanilla Extract, and CSS optimization support
|
|
15
|
+
- **Development Efficiency**: Fast development cycle with stub functionality
|
|
16
|
+
- **Automation**: Automatic generation of package.json and exports
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @fastkit/plugboy
|
|
22
|
+
# or
|
|
23
|
+
pnpm add @fastkit/plugboy
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Basic Usage
|
|
27
|
+
|
|
28
|
+
### CLI Commands
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Build entire project
|
|
32
|
+
plugboy build
|
|
33
|
+
|
|
34
|
+
# Generate development stub (fast development)
|
|
35
|
+
plugboy stub
|
|
36
|
+
|
|
37
|
+
# Sync package.json settings
|
|
38
|
+
plugboy json
|
|
39
|
+
|
|
40
|
+
# Delete distribution
|
|
41
|
+
plugboy clean
|
|
42
|
+
|
|
43
|
+
# Generate new workspace
|
|
44
|
+
plugboy generate [workspaceName]
|
|
45
|
+
# or
|
|
46
|
+
plugboy gen [workspaceName]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Workspace Configuration
|
|
50
|
+
|
|
51
|
+
**`plugboy.workspace.ts`**:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { defineWorkspaceConfig } from '@fastkit/plugboy';
|
|
55
|
+
|
|
56
|
+
export default defineWorkspaceConfig({
|
|
57
|
+
entries: {
|
|
58
|
+
'.': './src/index.ts',
|
|
59
|
+
'./utils': './src/utils.ts'
|
|
60
|
+
},
|
|
61
|
+
plugins: [
|
|
62
|
+
// Plugin configuration
|
|
63
|
+
],
|
|
64
|
+
dts: {
|
|
65
|
+
// TypeScript type definition configuration
|
|
66
|
+
},
|
|
67
|
+
optimizeCSS: true
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Project Configuration
|
|
72
|
+
|
|
73
|
+
**`plugboy.project.ts`**:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { defineProjectConfig } from '@fastkit/plugboy';
|
|
77
|
+
|
|
78
|
+
export default defineProjectConfig({
|
|
79
|
+
workspacesDir: 'packages',
|
|
80
|
+
peerDependencies: {
|
|
81
|
+
'vue': '^3.5.0'
|
|
82
|
+
},
|
|
83
|
+
scripts: [
|
|
84
|
+
{
|
|
85
|
+
name: 'TypeScript',
|
|
86
|
+
scripts: {
|
|
87
|
+
build: 'plugboy build',
|
|
88
|
+
stub: 'plugboy stub',
|
|
89
|
+
typecheck: 'tsc --noEmit'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## API
|
|
97
|
+
|
|
98
|
+
### defineWorkspaceConfig
|
|
99
|
+
|
|
100
|
+
#### Entry Point Configuration
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
export default defineWorkspaceConfig({
|
|
104
|
+
entries: {
|
|
105
|
+
'.': './src/index.ts', // Main entry
|
|
106
|
+
'./components': './src/components.ts', // Sub entry
|
|
107
|
+
'./styles': { // Entry with CSS
|
|
108
|
+
src: './src/styles.ts',
|
|
109
|
+
css: true
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Plugin Configuration
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { createSassPlugin } from '@fastkit/plugboy-sass-plugin';
|
|
119
|
+
import { createVueJSXPlugin } from '@fastkit/plugboy-vue-jsx-plugin';
|
|
120
|
+
|
|
121
|
+
export default defineWorkspaceConfig({
|
|
122
|
+
plugins: [
|
|
123
|
+
createSassPlugin(),
|
|
124
|
+
createVueJSXPlugin()
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### TypeScript Type Definition Configuration
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
export default defineWorkspaceConfig({
|
|
133
|
+
dts: {
|
|
134
|
+
preserveType: [
|
|
135
|
+
// Custom type preservation configuration
|
|
136
|
+
],
|
|
137
|
+
normalizers: [
|
|
138
|
+
// Type definition normalization functions
|
|
139
|
+
(dts) => dts.replace(/unwanted-pattern/g, '')
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### defineProjectConfig
|
|
146
|
+
|
|
147
|
+
#### Workspace Management
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
export default defineProjectConfig({
|
|
151
|
+
workspacesDir: 'packages',
|
|
152
|
+
peerDependencies: {
|
|
153
|
+
'react': '^18.0.0',
|
|
154
|
+
'vue': '^3.5.0'
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### Script Templates
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
export default defineProjectConfig({
|
|
163
|
+
scripts: [
|
|
164
|
+
{
|
|
165
|
+
name: 'TypeScript',
|
|
166
|
+
scripts: {
|
|
167
|
+
build: 'plugboy build',
|
|
168
|
+
clean: 'rm -rf dist',
|
|
169
|
+
typecheck: 'tsc --noEmit'
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'TypeScript with CSS',
|
|
174
|
+
scripts: {
|
|
175
|
+
build: 'plugboy build',
|
|
176
|
+
lint: 'eslint . && stylelint "**/*.css"'
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Plugin System
|
|
184
|
+
|
|
185
|
+
### Built-in Plugins
|
|
186
|
+
|
|
187
|
+
- **@fastkit/plugboy-sass-plugin**: Sass/SCSS support
|
|
188
|
+
- **@fastkit/plugboy-vanilla-extract-plugin**: Vanilla Extract support
|
|
189
|
+
- **@fastkit/plugboy-vue-jsx-plugin**: Vue JSX support
|
|
190
|
+
|
|
191
|
+
### Custom Plugins
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
import type { Plugin } from '@fastkit/plugboy';
|
|
195
|
+
|
|
196
|
+
const customPlugin = (): Plugin => ({
|
|
197
|
+
name: 'custom-plugin',
|
|
198
|
+
setup(workspace) {
|
|
199
|
+
// Plugin initialization
|
|
200
|
+
workspace.hooks.buildStart?.tap('custom-plugin', () => {
|
|
201
|
+
console.log('Build started');
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
export default defineWorkspaceConfig({
|
|
207
|
+
plugins: [customPlugin()]
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Development Workflow
|
|
212
|
+
|
|
213
|
+
### Fast Development Cycle
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# 1. Initial build
|
|
217
|
+
pnpm build
|
|
218
|
+
|
|
219
|
+
# 2. Development mode (fast)
|
|
220
|
+
pnpm stub
|
|
221
|
+
|
|
222
|
+
# 3. Start development server
|
|
223
|
+
pnpm dev
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Monorepo Management
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Create new package
|
|
230
|
+
plugboy gen my-new-package
|
|
231
|
+
|
|
232
|
+
# Build entire project
|
|
233
|
+
plugboy build
|
|
234
|
+
|
|
235
|
+
# Specific package only
|
|
236
|
+
cd packages/my-package
|
|
237
|
+
plugboy build
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Configuration Examples
|
|
241
|
+
|
|
242
|
+
### CSS Integration Project
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
// plugboy.workspace.ts
|
|
246
|
+
import { defineWorkspaceConfig } from '@fastkit/plugboy';
|
|
247
|
+
import { createSassPlugin } from '@fastkit/plugboy-sass-plugin';
|
|
248
|
+
|
|
249
|
+
export default defineWorkspaceConfig({
|
|
250
|
+
entries: {
|
|
251
|
+
'.': {
|
|
252
|
+
src: './src/index.ts',
|
|
253
|
+
css: true
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
plugins: [
|
|
257
|
+
createSassPlugin()
|
|
258
|
+
],
|
|
259
|
+
optimizeCSS: {
|
|
260
|
+
combineRules: {
|
|
261
|
+
rules: [':root']
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Vue.js Project
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
// plugboy.workspace.ts
|
|
271
|
+
import { defineWorkspaceConfig } from '@fastkit/plugboy';
|
|
272
|
+
import { createVueJSXPlugin } from '@fastkit/plugboy-vue-jsx-plugin';
|
|
273
|
+
import { createSassPlugin } from '@fastkit/plugboy-sass-plugin';
|
|
274
|
+
|
|
275
|
+
export default defineWorkspaceConfig({
|
|
276
|
+
entries: {
|
|
277
|
+
'.': './src/index.ts'
|
|
278
|
+
},
|
|
279
|
+
plugins: [
|
|
280
|
+
createVueJSXPlugin(),
|
|
281
|
+
createSassPlugin()
|
|
282
|
+
],
|
|
283
|
+
external: ['vue']
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Hook System
|
|
288
|
+
|
|
289
|
+
### Build Hooks
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
export default defineWorkspaceConfig({
|
|
293
|
+
hooks: {
|
|
294
|
+
buildStart: () => {
|
|
295
|
+
console.log('Build starting...');
|
|
296
|
+
},
|
|
297
|
+
buildEnd: (result) => {
|
|
298
|
+
console.log('Build completed:', result);
|
|
299
|
+
},
|
|
300
|
+
buildError: (error) => {
|
|
301
|
+
console.error('Build failed:', error);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Type Definition Management
|
|
308
|
+
|
|
309
|
+
### Automatic Type Definition Generation
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
export default defineWorkspaceConfig({
|
|
313
|
+
dts: {
|
|
314
|
+
preserveType: [
|
|
315
|
+
// Preserve external package types
|
|
316
|
+
'external-package-types'
|
|
317
|
+
],
|
|
318
|
+
normalizers: [
|
|
319
|
+
// Normalization and optimization of type definitions
|
|
320
|
+
(dts) => dts
|
|
321
|
+
.replace(/unnecessary-types/g, '')
|
|
322
|
+
.replace(/import\("complex-path"\)/g, 'SimpleType')
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Performance Optimization
|
|
329
|
+
|
|
330
|
+
### Build Optimization
|
|
331
|
+
|
|
332
|
+
- **Parallel Processing**: Simultaneous building of multiple entries
|
|
333
|
+
- **Incremental**: Rebuild only changed parts
|
|
334
|
+
- **Cache**: Utilize cached build results
|
|
335
|
+
- **Tree Shaking**: Remove unused code
|
|
336
|
+
|
|
337
|
+
### Development Optimization
|
|
338
|
+
|
|
339
|
+
- **Stub Mode**: Symbolic links to actual files
|
|
340
|
+
- **Hot Reload**: Immediate reflection of file changes
|
|
341
|
+
- **TypeScript**: Fast type checking
|
|
342
|
+
|
|
343
|
+
## Dependencies
|
|
344
|
+
|
|
345
|
+
### Main Dependencies
|
|
346
|
+
|
|
347
|
+
- `esbuild`: High-speed JavaScript builder
|
|
348
|
+
- `tsdown`: TypeScript build tool
|
|
349
|
+
- `cac`: CLI creation library
|
|
350
|
+
- `glob`: File matching
|
|
351
|
+
- `cssnano`: CSS optimization
|
|
352
|
+
|
|
353
|
+
## License
|
|
354
|
+
|
|
355
|
+
MIT
|
package/dist/cli.d.mts
ADDED
package/dist/cli.mjs
CHANGED
|
@@ -1,135 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
generateWorkspace,
|
|
3
|
-
getWorkspace
|
|
4
|
-
} from "./chunk-MN572VU2.mjs";
|
|
5
|
-
|
|
6
|
-
// src/cli.ts
|
|
1
|
+
import { i as getWorkspace, t as generateWorkspace } from "./workspace-BqcryYAT.mjs";
|
|
7
2
|
import { cac } from "cac";
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
name: "@fastkit/plugboy",
|
|
12
|
-
version: "0.2.7",
|
|
13
|
-
description: "",
|
|
14
|
-
keywords: [],
|
|
15
|
-
repository: {
|
|
16
|
-
type: "git",
|
|
17
|
-
url: "git+https://github.com/dadajam4/fastkit.git"
|
|
18
|
-
},
|
|
19
|
-
license: "MIT",
|
|
20
|
-
author: "dadajam4",
|
|
21
|
-
type: "module",
|
|
22
|
-
exports: {
|
|
23
|
-
"./package.json": "./package.json",
|
|
24
|
-
"./dependencies/bundle-require": {
|
|
25
|
-
import: "./dist/dependencies/bundle-require.mjs",
|
|
26
|
-
types: "./dist/dependencies/bundle-require.d.ts"
|
|
27
|
-
},
|
|
28
|
-
"./dependencies/cac": {
|
|
29
|
-
import: "./dist/dependencies/cac.mjs",
|
|
30
|
-
types: "./dist/dependencies/cac.d.ts"
|
|
31
|
-
},
|
|
32
|
-
"./dependencies/esbuild": {
|
|
33
|
-
import: "./dist/dependencies/esbuild.mjs",
|
|
34
|
-
types: "./dist/dependencies/esbuild.d.ts"
|
|
35
|
-
},
|
|
36
|
-
"./dependencies/glob": {
|
|
37
|
-
import: "./dist/dependencies/glob.mjs",
|
|
38
|
-
types: "./dist/dependencies/glob.d.ts"
|
|
39
|
-
},
|
|
40
|
-
"./dependencies/inquirer": {
|
|
41
|
-
import: "./dist/dependencies/inquirer.mjs",
|
|
42
|
-
types: "./dist/dependencies/inquirer.d.ts"
|
|
43
|
-
},
|
|
44
|
-
"./dependencies/pkg-types": {
|
|
45
|
-
import: "./dist/dependencies/pkg-types.mjs",
|
|
46
|
-
types: "./dist/dependencies/pkg-types.d.ts"
|
|
47
|
-
},
|
|
48
|
-
"./dependencies/sort-package-json": {
|
|
49
|
-
import: "./dist/dependencies/sort-package-json.mjs",
|
|
50
|
-
types: "./dist/dependencies/sort-package-json.d.ts"
|
|
51
|
-
},
|
|
52
|
-
"./dependencies/tsup": {
|
|
53
|
-
import: "./dist/dependencies/tsup.mjs",
|
|
54
|
-
types: "./dist/dependencies/tsup.d.ts"
|
|
55
|
-
},
|
|
56
|
-
"./env": {
|
|
57
|
-
types: "./env.d.ts"
|
|
58
|
-
},
|
|
59
|
-
".": {
|
|
60
|
-
import: "./dist/plugboy.mjs",
|
|
61
|
-
types: "./dist/plugboy.d.ts"
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
bin: {
|
|
65
|
-
plugboy: "./cli.mjs"
|
|
66
|
-
},
|
|
67
|
-
files: [
|
|
68
|
-
"env.d.ts",
|
|
69
|
-
"cli.mjs",
|
|
70
|
-
"dist"
|
|
71
|
-
],
|
|
72
|
-
scripts: {
|
|
73
|
-
build: "tsup",
|
|
74
|
-
clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
75
|
-
eslint: "eslint . --ext ts,tsx,js,vue,html,yaml",
|
|
76
|
-
"eslint:fix": "eslint . --ext ts,tsx,js,vue,html,yaml --fix",
|
|
77
|
-
lint: "pnpm run eslint",
|
|
78
|
-
format: "pnpm run eslint:fix",
|
|
79
|
-
typecheck: "tsc --noEmit --skipLibCheck",
|
|
80
|
-
test: "vitest run"
|
|
81
|
-
},
|
|
82
|
-
dependencies: {
|
|
83
|
-
"@inquirer/prompts": "^5.3.0",
|
|
84
|
-
"bundle-require": "^5.0.0",
|
|
85
|
-
cac: "^6.7.14",
|
|
86
|
-
cssnano: "^7.0.4",
|
|
87
|
-
esbuild: "^0.23.0",
|
|
88
|
-
execa: "^9.3.0",
|
|
89
|
-
glob: "^11.0.0",
|
|
90
|
-
"pkg-types": "^1.1.3",
|
|
91
|
-
"sort-package-json": "^2.10.0",
|
|
92
|
-
tsup: "^8.2.1"
|
|
93
|
-
}
|
|
94
|
-
};
|
|
4
|
+
//#region package.json
|
|
5
|
+
var version = "1.0.0-next.0";
|
|
95
6
|
|
|
96
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/cli.ts
|
|
97
9
|
async function main() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"generate [workspaceName]",
|
|
124
|
-
"Generate a workspace for your project."
|
|
125
|
-
).alias("gen").action(async (workspaceName, options) => {
|
|
126
|
-
await generateWorkspace(workspaceName);
|
|
127
|
-
});
|
|
128
|
-
cli.help();
|
|
129
|
-
cli.parse();
|
|
10
|
+
const cli = cac("plugboy");
|
|
11
|
+
cli.version(version);
|
|
12
|
+
cli.command("json", "Apply workspace settings in package.json.").action(async (files, options) => {
|
|
13
|
+
await (await getWorkspace()).preparePackageJSON();
|
|
14
|
+
});
|
|
15
|
+
cli.command("stub", "Link workspace distributions and source directories.").action(async (files, options) => {
|
|
16
|
+
const workspace = await getWorkspace();
|
|
17
|
+
await workspace.preparePackageJSON();
|
|
18
|
+
await workspace.stub();
|
|
19
|
+
});
|
|
20
|
+
cli.command("build", "Guess all entries in the workspace and bundle the source code.").action(async (files, options) => {
|
|
21
|
+
const workspace = await getWorkspace();
|
|
22
|
+
await workspace.preparePackageJSON();
|
|
23
|
+
await workspace.build();
|
|
24
|
+
});
|
|
25
|
+
cli.command("clean", "Deletes the distribution directory of the workspace.").action(async (files, options) => {
|
|
26
|
+
const workspace = await getWorkspace();
|
|
27
|
+
await workspace.preparePackageJSON();
|
|
28
|
+
await workspace.clean();
|
|
29
|
+
});
|
|
30
|
+
cli.command("generate [workspaceName]", "Generate a workspace for your project.").alias("gen").action(async (workspaceName, options) => {
|
|
31
|
+
await generateWorkspace(workspaceName);
|
|
32
|
+
});
|
|
33
|
+
cli.help();
|
|
34
|
+
cli.parse();
|
|
130
35
|
}
|
|
131
36
|
main();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { main };
|
|
135
40
|
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["pkg.version"],"sources":["../package.json","../src/cli.ts"],"sourcesContent":["","import { cac } from 'cac';\nimport { getWorkspace, generateWorkspace } from './workspace';\nimport pkg from '../package.json';\n\nexport async function main() {\n const cli = cac('plugboy');\n cli.version(pkg.version);\n\n cli\n .command('json', 'Apply workspace settings in package.json.')\n .action(async (files, options) => {\n const workspace = await getWorkspace();\n await workspace.preparePackageJSON();\n });\n\n cli\n .command('stub', 'Link workspace distributions and source directories.')\n .action(async (files, options) => {\n const workspace = await getWorkspace();\n await workspace.preparePackageJSON();\n await workspace.stub();\n });\n\n cli\n .command(\n 'build',\n 'Guess all entries in the workspace and bundle the source code.',\n )\n .action(async (files, options) => {\n const workspace = await getWorkspace();\n await workspace.preparePackageJSON();\n await workspace.build();\n });\n\n cli\n .command('clean', 'Deletes the distribution directory of the workspace.')\n .action(async (files, options) => {\n const workspace = await getWorkspace();\n await workspace.preparePackageJSON();\n await workspace.clean();\n });\n\n cli\n .command(\n 'generate [workspaceName]',\n 'Generate a workspace for your project.',\n )\n .alias('gen')\n .action(async (workspaceName: string | undefined, options) => {\n await generateWorkspace(workspaceName);\n });\n\n cli.help();\n cli.parse();\n}\n\nmain();\n"],"mappings":";;;;;;;;ACIA,eAAsB,OAAO;CAC3B,MAAM,MAAM,IAAI,UAAU;AAC1B,KAAI,QAAQA,QAAY;AAExB,KACG,QAAQ,QAAQ,4CAA4C,CAC5D,OAAO,OAAO,OAAO,YAAY;AAEhC,SADkB,MAAM,cAAc,EACtB,oBAAoB;GACpC;AAEJ,KACG,QAAQ,QAAQ,uDAAuD,CACvE,OAAO,OAAO,OAAO,YAAY;EAChC,MAAM,YAAY,MAAM,cAAc;AACtC,QAAM,UAAU,oBAAoB;AACpC,QAAM,UAAU,MAAM;GACtB;AAEJ,KACG,QACC,SACA,iEACD,CACA,OAAO,OAAO,OAAO,YAAY;EAChC,MAAM,YAAY,MAAM,cAAc;AACtC,QAAM,UAAU,oBAAoB;AACpC,QAAM,UAAU,OAAO;GACvB;AAEJ,KACG,QAAQ,SAAS,uDAAuD,CACxE,OAAO,OAAO,OAAO,YAAY;EAChC,MAAM,YAAY,MAAM,cAAc;AACtC,QAAM,UAAU,oBAAoB;AACpC,QAAM,UAAU,OAAO;GACvB;AAEJ,KACG,QACC,4BACA,yCACD,CACA,MAAM,MAAM,CACZ,OAAO,OAAO,eAAmC,YAAY;AAC5D,QAAM,kBAAkB,cAAc;GACtC;AAEJ,KAAI,MAAM;AACV,KAAI,OAAO;;AAGb,MAAM"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import postcss, { Root } from "postcss";
|
|
2
|
+
|
|
3
|
+
//#region src/postcss/plugins/combine-rules.ts
|
|
4
|
+
function buildFilterFn(spec) {
|
|
5
|
+
return (rule) => {
|
|
6
|
+
if (typeof spec === "function") return spec(rule);
|
|
7
|
+
const { selector } = rule;
|
|
8
|
+
return spec.some((target) => {
|
|
9
|
+
if (typeof target === "string") return selector === target;
|
|
10
|
+
return target.test(selector);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function combineContainerRules(container, filter) {
|
|
15
|
+
const { nodes } = container;
|
|
16
|
+
if (!nodes) return;
|
|
17
|
+
const rules = nodes.filter(filter);
|
|
18
|
+
const combinedRules = [];
|
|
19
|
+
rules.forEach((rule) => {
|
|
20
|
+
const { selector } = rule;
|
|
21
|
+
let combinedRule = combinedRules.find((c) => c.selector === selector);
|
|
22
|
+
if (!combinedRule) {
|
|
23
|
+
combinedRule = {
|
|
24
|
+
selector,
|
|
25
|
+
rules: [],
|
|
26
|
+
container: rule
|
|
27
|
+
};
|
|
28
|
+
combinedRules.push(combinedRule);
|
|
29
|
+
}
|
|
30
|
+
combinedRule.rules.push(rule);
|
|
31
|
+
});
|
|
32
|
+
combinedRules.forEach((combinedRule) => {
|
|
33
|
+
combinedRule.rules.forEach((rule, index) => {
|
|
34
|
+
if (index === 0) return;
|
|
35
|
+
const { nodes } = rule;
|
|
36
|
+
if (!nodes) return;
|
|
37
|
+
nodes.forEach((node) => {
|
|
38
|
+
combinedRule.container.append(node.clone());
|
|
39
|
+
});
|
|
40
|
+
rule.remove();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function combineRules(css, opts) {
|
|
45
|
+
const root = css instanceof Root ? css : postcss.parse(css);
|
|
46
|
+
const filter = buildFilterFn(opts.rules);
|
|
47
|
+
combineContainerRules(root, filter);
|
|
48
|
+
root.walkAtRules((atRule) => {
|
|
49
|
+
combineContainerRules(atRule, filter);
|
|
50
|
+
});
|
|
51
|
+
return root;
|
|
52
|
+
}
|
|
53
|
+
const PLUGIN_NAME = "combine-rules";
|
|
54
|
+
function CombineRules(opts) {
|
|
55
|
+
return {
|
|
56
|
+
postcssPlugin: PLUGIN_NAME,
|
|
57
|
+
Once(root) {
|
|
58
|
+
combineRules(root, opts);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
CombineRules.postcss = true;
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { CombineRules };
|
|
66
|
+
//# sourceMappingURL=combine-rules-CWp-M491.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combine-rules-CWp-M491.mjs","names":[],"sources":["../src/postcss/plugins/combine-rules.ts"],"sourcesContent":["import postcss, { Plugin, Root, Container, Rule } from 'postcss';\n\nexport type RuleFilter = string | RegExp;\n\nexport type RuleSpecFn = (rule: Rule) => boolean;\n\nexport type RuleSpec = RuleFilter[] | RuleSpecFn;\n\nexport interface CombineRulesOptions {\n rules: RuleSpec;\n}\n\nfunction buildFilterFn(spec: RuleSpec): RuleSpecFn {\n return (rule) => {\n if (typeof spec === 'function') return spec(rule);\n const { selector } = rule;\n return spec.some((target) => {\n if (typeof target === 'string') return selector === target;\n return target.test(selector);\n });\n };\n}\n\nexport function combineContainerRules(\n container: Container,\n filter: RuleSpecFn,\n) {\n const { nodes } = container;\n if (!nodes) return;\n\n const rules: Rule[] = (nodes as Rule[]).filter(filter);\n const combinedRules: { selector: string; rules: Rule[]; container: Rule }[] =\n [];\n rules.forEach((rule) => {\n const { selector } = rule;\n let combinedRule = combinedRules.find((c) => c.selector === selector);\n if (!combinedRule) {\n combinedRule = {\n selector,\n rules: [],\n container: rule,\n };\n combinedRules.push(combinedRule);\n }\n combinedRule.rules.push(rule);\n });\n\n combinedRules.forEach((combinedRule) => {\n combinedRule.rules.forEach((rule, index) => {\n if (index === 0) return;\n\n const { nodes } = rule;\n if (!nodes) return;\n nodes.forEach((node) => {\n combinedRule.container.append(node.clone());\n });\n rule.remove();\n });\n });\n}\n\nexport function combineRules(\n css: string | { toString(): string } | Root,\n opts: CombineRulesOptions,\n): Root {\n const root = css instanceof Root ? css : postcss.parse(css);\n const filter = buildFilterFn(opts.rules);\n combineContainerRules(root, filter);\n root.walkAtRules((atRule) => {\n combineContainerRules(atRule, filter);\n });\n return root;\n}\n\nconst PLUGIN_NAME = 'combine-rules';\n\nexport function CombineRules(opts: CombineRulesOptions): Plugin {\n return {\n postcssPlugin: PLUGIN_NAME,\n Once(root) {\n combineRules(root, opts);\n },\n };\n}\n\nCombineRules.postcss = true;\n\nexport default CombineRules;\n"],"mappings":";;;AAYA,SAAS,cAAc,MAA4B;AACjD,SAAQ,SAAS;AACf,MAAI,OAAO,SAAS,WAAY,QAAO,KAAK,KAAK;EACjD,MAAM,EAAE,aAAa;AACrB,SAAO,KAAK,MAAM,WAAW;AAC3B,OAAI,OAAO,WAAW,SAAU,QAAO,aAAa;AACpD,UAAO,OAAO,KAAK,SAAS;IAC5B;;;AAIN,SAAgB,sBACd,WACA,QACA;CACA,MAAM,EAAE,UAAU;AAClB,KAAI,CAAC,MAAO;CAEZ,MAAM,QAAiB,MAAiB,OAAO,OAAO;CACtD,MAAM,gBACJ,EAAE;AACJ,OAAM,SAAS,SAAS;EACtB,MAAM,EAAE,aAAa;EACrB,IAAI,eAAe,cAAc,MAAM,MAAM,EAAE,aAAa,SAAS;AACrE,MAAI,CAAC,cAAc;AACjB,kBAAe;IACb;IACA,OAAO,EAAE;IACT,WAAW;IACZ;AACD,iBAAc,KAAK,aAAa;;AAElC,eAAa,MAAM,KAAK,KAAK;GAC7B;AAEF,eAAc,SAAS,iBAAiB;AACtC,eAAa,MAAM,SAAS,MAAM,UAAU;AAC1C,OAAI,UAAU,EAAG;GAEjB,MAAM,EAAE,UAAU;AAClB,OAAI,CAAC,MAAO;AACZ,SAAM,SAAS,SAAS;AACtB,iBAAa,UAAU,OAAO,KAAK,OAAO,CAAC;KAC3C;AACF,QAAK,QAAQ;IACb;GACF;;AAGJ,SAAgB,aACd,KACA,MACM;CACN,MAAM,OAAO,eAAe,OAAO,MAAM,QAAQ,MAAM,IAAI;CAC3D,MAAM,SAAS,cAAc,KAAK,MAAM;AACxC,uBAAsB,MAAM,OAAO;AACnC,MAAK,aAAa,WAAW;AAC3B,wBAAsB,QAAQ,OAAO;GACrC;AACF,QAAO;;AAGT,MAAM,cAAc;AAEpB,SAAgB,aAAa,MAAmC;AAC9D,QAAO;EACL,eAAe;EACf,KAAK,MAAM;AACT,gBAAa,MAAM,KAAK;;EAE3B;;AAGH,aAAa,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "bundle-require";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export * from "bundle-require"
|
|
2
|
+
|
|
3
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "cac";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export * from "cac"
|
|
2
|
+
|
|
3
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "glob";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export * from "glob"
|
|
2
|
+
|
|
3
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@inquirer/prompts";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export * from "@inquirer/prompts"
|
|
2
|
+
|
|
3
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "pkg-types";
|