@driveflux/fab 1.0.5 → 1.0.8
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/.turbo/turbo-build.log +7 -4
- package/CHANGELOG.md +18 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +6 -2
- package/dist/clean.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/build.ts +87 -76
- package/src/clean.ts +7 -3
- package/src/config.ts +18 -14
- package/src/create.ts +17 -9
- package/src/types.ts +1 -1
- package/src/utils.ts +6 -7
- package/templates/backend/src/index.ts +1 -0
- package/templates/frontend/package.json +1 -1
- package/templates/frontend/src/index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
[43m[30m WARN [39m[49m Issue while reading "/Users/flux/Projects/flux-master/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
1
2
|
|
|
2
|
-
> @driveflux/fab@1.0.
|
|
3
|
+
> @driveflux/fab@1.0.8 build /Users/flux/Projects/flux-master/packages/fab
|
|
3
4
|
> pnpm build:js && pnpm build:types
|
|
4
5
|
|
|
6
|
+
[43m[30m WARN [39m[49m Issue while reading "/Users/flux/Projects/flux-master/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
5
7
|
|
|
6
|
-
> @driveflux/fab@1.0.
|
|
8
|
+
> @driveflux/fab@1.0.8 build:js /Users/flux/Projects/flux-master/packages/fab
|
|
7
9
|
> swc src --strip-leading-paths -d dist
|
|
8
10
|
|
|
9
|
-
Successfully compiled: 7 files with swc (
|
|
11
|
+
Successfully compiled: 7 files with swc (229.69ms)
|
|
12
|
+
[43m[30m WARN [39m[49m Issue while reading "/Users/flux/Projects/flux-master/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
10
13
|
|
|
11
|
-
> @driveflux/fab@1.0.
|
|
14
|
+
> @driveflux/fab@1.0.8 build:types /Users/flux/Projects/flux-master/packages/fab
|
|
12
15
|
> tsc --build --emitDeclarationOnly
|
|
13
16
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @driveflux/fab
|
|
2
2
|
|
|
3
|
+
## 1.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Minor updates on build
|
|
8
|
+
|
|
9
|
+
## 1.0.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Upgraded all packages
|
|
14
|
+
|
|
15
|
+
## 1.0.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Minor diversion version fix
|
|
20
|
+
|
|
3
21
|
## 1.0.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAS,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAK7C,UAAU,YAAa,SAAQ,WAAW,EAAE,sBAAsB,EAAE,YAAY;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,UAAU,sBAAuB,SAAQ,WAAW;IAClD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;CACjC;AAaD,eAAO,MAAM,KAAK,gBAAuB,YAAY,kBA2BpD,CAAA;AAED,eAAO,MAAM,YAAY,gBAAuB,YAAY,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAS,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAK7C,UAAU,YAAa,SAAQ,WAAW,EAAE,sBAAsB,EAAE,YAAY;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,UAAU,sBAAuB,SAAQ,WAAW;IAClD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;CACjC;AAaD,eAAO,MAAM,KAAK,gBAAuB,YAAY,kBA2BpD,CAAA;AAED,eAAO,MAAM,YAAY,gBAAuB,YAAY,kBAgB3D,CAAA;AAED,eAAO,MAAM,UAAU,gBAAuB,WAAW,kBAIxD,CAAA;AAED,eAAO,MAAM,QAAQ,gBAAuB,WAAW,kBAkBtD,CAAA;AAED,eAAO,MAAM,eAAe,gBAAuB,sBAAsB,sBAoBxE,CAAA;AAmLD,eAAO,MAAM,QAAQ,gBAAuB,WAAW,kBAStD,CAAA"}
|
package/dist/build.js
CHANGED
|
@@ -65,6 +65,10 @@ function _non_iterable_rest() {
|
|
|
65
65
|
function _sliced_to_array(arr, i) {
|
|
66
66
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
67
67
|
}
|
|
68
|
+
function _type_of(obj) {
|
|
69
|
+
"@swc/helpers - typeof";
|
|
70
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
71
|
+
}
|
|
68
72
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
69
73
|
if (!o) return;
|
|
70
74
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -424,7 +428,7 @@ export var makeBaseExports = function() {
|
|
|
424
428
|
if (!exp) {
|
|
425
429
|
throw new Error('No exports found');
|
|
426
430
|
}
|
|
427
|
-
if (typeof exp !== 'object' && Array.isArray(exp)) {
|
|
431
|
+
if ((typeof exp === "undefined" ? "undefined" : _type_of(exp)) !== 'object' && Array.isArray(exp)) {
|
|
428
432
|
throw new Error('Exports must be an object');
|
|
429
433
|
}
|
|
430
434
|
return [
|
|
@@ -535,7 +539,7 @@ var extractBaseExportsFromEntry = function() {
|
|
|
535
539
|
throw new Error("Only 1 wildcard at the end of the export path is allowed. Provided ".concat(key));
|
|
536
540
|
}
|
|
537
541
|
exportTypeKey = type === 'cjs' ? 'require' : 'types';
|
|
538
|
-
if (typeof value !== 'object' || !value || Array.isArray(value) || !(exportTypeKey in value) || typeof value[exportTypeKey] === 'undefined') {
|
|
542
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object' || !value || Array.isArray(value) || !(exportTypeKey in value) || typeof value[exportTypeKey] === 'undefined') {
|
|
539
543
|
throw new Error("Missing key ".concat(exportTypeKey, " from the exports map of ").concat(key, ". If this is desired, then set it to null."));
|
|
540
544
|
}
|
|
541
545
|
exportKeyValue = value[exportTypeKey];
|
package/dist/clean.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../src/clean.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,WAAW,YAAa,SAAQ,WAAW,EAAE,MAAM;IACvD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED,eAAO,MAAM,KAAK,gBAAsB,YAAY,
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../src/clean.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,WAAW,YAAa,SAAQ,WAAW,EAAE,MAAM;IACvD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED,eAAO,MAAM,KAAK,gBAAsB,YAAY,kBAiCnD,CAAA"}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAErD,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,QAAA,MAAM,gBAAgB;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAErD,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,QAAA,MAAM,gBAAgB;;;;;;;;;;;;EAMV,CAAA;AAEZ,eAAO,MAAM,WAAW,aAAoB,kBAAkB;;;;EAiB7D,CAAA"}
|
package/dist/create.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAIA,UAAU,aAAa;IACrB,QAAQ,EAAE,SAAS,GAAG,UAAU,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED,eAAO,MAAM,MAAM,+
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAIA,UAAU,aAAa;IACrB,QAAQ,EAAE,SAAS,GAAG,UAAU,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED,eAAO,MAAM,MAAM,+FAMhB,aAAa,kBAuCf,CAAA"}
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,oBAAoB,CAAA;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,UAAU,sBAAuB,SAAQ,WAAW;IAClD,OAAO,EAAE,MAAM,OAAO,aAAa,CAAA;CACpC;AAED,QAAA,MAAM,aAAa;;;;CAIT,CAAA;AAEV,eAAO,MAAM,SAAS,QAAe,MAAM,kBAS1C,CAAA;AAED,eAAO,MAAM,UAAU,QAAe,MAAM,QAAQ,MAAM,EAAE,WAAW,YAAY,qBAelF,CAAA;AAED,eAAO,MAAM,mBAAmB,kCAAyC,sBAAsB,kBA2B9F,CAAA;AAED,eAAO,MAAM,UAAU,cAGtB,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAO,SAAS,WAAW,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,oBAAoB,CAAA;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,UAAU,sBAAuB,SAAQ,WAAW;IAClD,OAAO,EAAE,MAAM,OAAO,aAAa,CAAA;CACpC;AAED,QAAA,MAAM,aAAa;;;;CAIT,CAAA;AAEV,eAAO,MAAM,SAAS,QAAe,MAAM,kBAS1C,CAAA;AAED,eAAO,MAAM,UAAU,QAAe,MAAM,QAAQ,MAAM,EAAE,WAAW,YAAY,qBAelF,CAAA;AAED,eAAO,MAAM,mBAAmB,kCAAyC,sBAAsB,kBA2B9F,CAAA;AAED,eAAO,MAAM,UAAU,cAGtB,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAO,SAAS,WAAW,CAAC,GAAG,MAK3D,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/fab",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"lodash.merge": "^4.6.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@swc-node/register": "
|
|
21
|
+
"@swc-node/register": "1.9.0",
|
|
22
22
|
"@swc/cli": "^0.3.12",
|
|
23
|
-
"@swc/core": "1.
|
|
23
|
+
"@swc/core": "1.6.3",
|
|
24
24
|
"@types/lodash.merge": "^4.6.9",
|
|
25
25
|
"del": "^7.1.0",
|
|
26
26
|
"del-cli": "^5.1.0",
|
package/src/build.ts
CHANGED
|
@@ -57,24 +57,26 @@ export const build = async (rawOptions?: BuildOptions) => {
|
|
|
57
57
|
await Promise.all(promises)
|
|
58
58
|
|
|
59
59
|
// Make exports for CJS
|
|
60
|
-
if(!options.noCJS) {
|
|
60
|
+
if (!options.noCJS) {
|
|
61
61
|
await makeBaseExports(options)
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export const copyVerbatim = async (rawOptions?: BuildOptions) => {
|
|
66
66
|
const options = merge({}, getDefaultOptions(), rawOptions)
|
|
67
|
-
if(options.copyVerbatim?.length) {
|
|
67
|
+
if (options.copyVerbatim?.length) {
|
|
68
68
|
const cwd = options.cwd ?? process.cwd()
|
|
69
69
|
const destination = options.destination ?? getDefaultOptions().destination
|
|
70
|
-
await Promise.all(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
await Promise.all(
|
|
71
|
+
options.copyVerbatim.map(async (fileOrFolderRaw) => {
|
|
72
|
+
const fileOrFolder = `src/${fileOrFolderRaw.replace(/^(\/)*src/, '')}`
|
|
73
|
+
const targetPath = path.resolve(destination, fileOrFolder).replace('/src', '')
|
|
74
|
+
const targetPathCjs = path.resolve(destination, 'cjs', fileOrFolder).replace('/src', '')
|
|
75
|
+
await ensureDir(path.dirname(targetPath))
|
|
76
|
+
await fs.cp(path.resolve(cwd, fileOrFolder), targetPath, { recursive: true })
|
|
77
|
+
await fs.cp(path.resolve(cwd, fileOrFolder), targetPathCjs, { recursive: true })
|
|
78
|
+
})
|
|
79
|
+
)
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
|
|
@@ -91,7 +93,9 @@ export const buildCjs = async (rawOptions?: BaseOptions) => {
|
|
|
91
93
|
const cjsPath = path.resolve(destination, 'cjs')
|
|
92
94
|
await validatePackageJson({ command: 'swc', cwd })
|
|
93
95
|
// We start by emitting the CJS files
|
|
94
|
-
await runCommand(`pnpm`, ['swc', 'src', '-C', 'module.type=commonjs', '--strip-leading-paths', '-d', cjsPath], {
|
|
96
|
+
await runCommand(`pnpm`, ['swc', 'src', '-C', 'module.type=commonjs', '--strip-leading-paths', '-d', cjsPath], {
|
|
97
|
+
cwd
|
|
98
|
+
})
|
|
95
99
|
const targetPath = path.resolve(cwd, cjsPath, 'package.json')
|
|
96
100
|
await ensureDir(path.dirname(targetPath))
|
|
97
101
|
await fs.writeFile(
|
|
@@ -186,75 +190,78 @@ const extractBaseExportsFromEntry = async (
|
|
|
186
190
|
throw new Error(`Only strings are allowed in the "${exportTypeKey}" field`)
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
const asteriskPosition = exportKeyValue
|
|
193
|
+
const asteriskPosition = exportKeyValue
|
|
194
|
+
.replace('./', '')
|
|
195
|
+
.split('/')
|
|
196
|
+
.findIndex((p) => p.startsWith('*'))
|
|
190
197
|
const paths = await parseExportPath(exportKeyValue, cwd)
|
|
191
198
|
|
|
192
|
-
const targetFiles = Promise.all(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
const targetFiles = Promise.all(
|
|
200
|
+
paths.map(async (p) => {
|
|
201
|
+
let finalKey = key
|
|
202
|
+
if (hasWildcard) {
|
|
203
|
+
finalKey = key.replace(
|
|
204
|
+
'*',
|
|
205
|
+
p
|
|
206
|
+
.split('/')
|
|
207
|
+
.slice(asteriskPosition, asteriskPosition + 1)
|
|
208
|
+
.join('/')
|
|
209
|
+
)
|
|
210
|
+
}
|
|
203
211
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
212
|
+
if (finalKey === '.' || finalKey === './') {
|
|
213
|
+
finalKey = 'index'
|
|
214
|
+
}
|
|
207
215
|
|
|
208
|
-
|
|
209
|
-
|
|
216
|
+
let content = ''
|
|
217
|
+
let targetFile: string = ''
|
|
210
218
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (type === 'cjs') {
|
|
221
|
-
finalKey = await resolvePathWithExtension(finalKey, 'cjs')
|
|
222
|
-
const importPaths = geImportPaths(finalKey)
|
|
223
|
-
const relativeImportPath = importPaths.relativeImportPath
|
|
224
|
-
targetFile = importPaths.targetFile
|
|
225
|
-
content = `module.exports = require('${formatImportPath(relativeImportPath)}')`
|
|
226
|
-
}
|
|
219
|
+
const geImportPaths = (importPath: string) => {
|
|
220
|
+
const targetFile = path.resolve(cwd, importPath)
|
|
221
|
+
const importFromPath = path.dirname(targetFile)
|
|
222
|
+
const fullImportPath = path.resolve(cwd, p)
|
|
223
|
+
const relativeImportPath = path.relative(importFromPath, fullImportPath)
|
|
224
|
+
return { relativeImportPath, fullImportPath, targetFile }
|
|
225
|
+
}
|
|
227
226
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
content = `export * from '${formatImportPath(relativeImportPath).replace('.d.ts', '')}'`
|
|
235
|
-
|
|
236
|
-
// Now, let's go inside that file and see if it exports "default" and add that into the content
|
|
237
|
-
const fileContent = await fs.readFile(importPaths.fullImportPath, 'utf-8')
|
|
238
|
-
if (/export default/.test(fileContent)) {
|
|
239
|
-
content += `\nexport { default } from '${formatImportPath(relativeImportPath)}'`
|
|
227
|
+
if (type === 'cjs') {
|
|
228
|
+
finalKey = await resolvePathWithExtension(finalKey, 'cjs')
|
|
229
|
+
const importPaths = geImportPaths(finalKey)
|
|
230
|
+
const relativeImportPath = importPaths.relativeImportPath
|
|
231
|
+
targetFile = importPaths.targetFile
|
|
232
|
+
content = `module.exports = require('${formatImportPath(relativeImportPath)}')`
|
|
240
233
|
}
|
|
241
|
-
}
|
|
242
234
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
235
|
+
if (type === 'types') {
|
|
236
|
+
finalKey = await resolvePathWithExtension(finalKey, 'd.ts')
|
|
237
|
+
const importPaths = geImportPaths(finalKey)
|
|
238
|
+
const relativeImportPath = importPaths.relativeImportPath
|
|
239
|
+
targetFile = importPaths.targetFile
|
|
240
|
+
// Typescript will complain about exprting .d.ts, so we just omt that
|
|
241
|
+
content = `export * from '${formatImportPath(relativeImportPath).replace('.d.ts', '')}'`
|
|
242
|
+
|
|
243
|
+
// Now, let's go inside that file and see if it exports "default" and add that into the content
|
|
244
|
+
const fileContent = await fs.readFile(importPaths.fullImportPath, 'utf-8')
|
|
245
|
+
if (/export default/.test(fileContent)) {
|
|
246
|
+
content += `\nexport { default } from '${formatImportPath(relativeImportPath)}'`
|
|
247
|
+
}
|
|
248
|
+
}
|
|
246
249
|
|
|
250
|
+
if (!content) {
|
|
251
|
+
throw new Error(`No content found for ${exportKeyValue}`)
|
|
252
|
+
}
|
|
247
253
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
254
|
+
const exportObj: BaseExport = {
|
|
255
|
+
type,
|
|
256
|
+
targetFile,
|
|
257
|
+
content
|
|
258
|
+
}
|
|
253
259
|
|
|
254
|
-
|
|
255
|
-
|
|
260
|
+
return exportObj
|
|
261
|
+
})
|
|
262
|
+
)
|
|
256
263
|
|
|
257
|
-
if(!targetFiles) {
|
|
264
|
+
if (!targetFiles) {
|
|
258
265
|
console.log(`⚠️ No CJS target files for ${key}`)
|
|
259
266
|
}
|
|
260
267
|
|
|
@@ -263,18 +270,18 @@ const extractBaseExportsFromEntry = async (
|
|
|
263
270
|
|
|
264
271
|
const resolvePathWithExtension = async (targetFile: string, extension: string) => {
|
|
265
272
|
try {
|
|
266
|
-
if((await fs.stat(targetFile)).isDirectory()) {
|
|
273
|
+
if ((await fs.stat(targetFile)).isDirectory()) {
|
|
267
274
|
return `${targetFile}/index.${extension}`
|
|
268
275
|
}
|
|
269
|
-
} catch(e) {
|
|
276
|
+
} catch (e) {
|
|
270
277
|
// Nothing to do here
|
|
271
278
|
}
|
|
272
279
|
|
|
273
|
-
if(targetFile.endsWith(extension)) {
|
|
280
|
+
if (targetFile.endsWith(extension)) {
|
|
274
281
|
return targetFile
|
|
275
282
|
}
|
|
276
283
|
|
|
277
|
-
if(targetFile.endsWith(`.js`)) {
|
|
284
|
+
if (targetFile.endsWith(`.js`)) {
|
|
278
285
|
return targetFile.replace(/\.js$/, `.${extension}`)
|
|
279
286
|
}
|
|
280
287
|
|
|
@@ -287,7 +294,7 @@ const formatImportPath = (exportPath: string): string => {
|
|
|
287
294
|
|
|
288
295
|
const parseExportPath = async (exportPath: string, cwd = process.cwd()): Promise<string[]> => {
|
|
289
296
|
const split = exportPath.split('*')
|
|
290
|
-
if(split.length === 1) {
|
|
297
|
+
if (split.length === 1) {
|
|
291
298
|
return [exportPath]
|
|
292
299
|
}
|
|
293
300
|
// Allow only 1 * in the path
|
|
@@ -300,9 +307,13 @@ const parseExportPath = async (exportPath: string, cwd = process.cwd()): Promise
|
|
|
300
307
|
|
|
301
308
|
export const buildEsm = async (rawOptions?: BaseOptions) => {
|
|
302
309
|
const options = merge({}, getDefaultOptions(), rawOptions)
|
|
303
|
-
await runCommand(
|
|
304
|
-
|
|
305
|
-
|
|
310
|
+
await runCommand(
|
|
311
|
+
`pnpm`,
|
|
312
|
+
['swc', 'src', '--strip-leading-paths', '-d', options.destination ?? getDefaultOptions().destination],
|
|
313
|
+
{
|
|
314
|
+
cwd: options.cwd
|
|
315
|
+
}
|
|
316
|
+
)
|
|
306
317
|
}
|
|
307
318
|
|
|
308
319
|
const parseExports = async (cwd = process.cwd()): Promise<PackageJson['exports']> => {
|
package/src/clean.ts
CHANGED
|
@@ -8,7 +8,13 @@ export interface CleanOptions extends BaseOptions, Config {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const clean = async (rawOptions: CleanOptions = getDefaultOptions()) => {
|
|
11
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
cwd,
|
|
13
|
+
destination,
|
|
14
|
+
cleanTs,
|
|
15
|
+
all,
|
|
16
|
+
doNotCleanup: rawDoNotCleanup
|
|
17
|
+
} = {
|
|
12
18
|
...getDefaultOptions(),
|
|
13
19
|
...rawOptions
|
|
14
20
|
}
|
|
@@ -34,6 +40,4 @@ export const clean = async (rawOptions: CleanOptions = getDefaultOptions()) => {
|
|
|
34
40
|
{ cwd }
|
|
35
41
|
)
|
|
36
42
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
43
|
}
|
package/src/config.ts
CHANGED
|
@@ -10,25 +10,27 @@ interface ParseConfigOptions {
|
|
|
10
10
|
cwd?: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const ConfigValidation = z
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const ConfigValidation = z
|
|
14
|
+
.object({
|
|
15
|
+
doNotCleanup: z.array(z.string()),
|
|
16
|
+
noCJS: z.boolean().optional(),
|
|
17
|
+
copyVerbatim: z.array(z.string())
|
|
18
|
+
})
|
|
19
|
+
.partial()
|
|
18
20
|
|
|
19
21
|
export const parseConfig = async (options?: ParseConfigOptions) => {
|
|
20
22
|
const cwd = options?.cwd || process.cwd()
|
|
21
23
|
|
|
22
|
-
let config: unknown
|
|
23
|
-
if(options?.config) {
|
|
24
|
+
let config: unknown
|
|
25
|
+
if (options?.config) {
|
|
24
26
|
config = options.config
|
|
25
|
-
} else if(options?.configFile) {
|
|
27
|
+
} else if (options?.configFile) {
|
|
26
28
|
config = await readConfigFile(path.resolve(cwd, options.configFile))
|
|
27
29
|
} else {
|
|
28
30
|
config = await findConfigFile(cwd)
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
if(!config) {
|
|
33
|
+
if (!config) {
|
|
32
34
|
return {}
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -37,17 +39,19 @@ export const parseConfig = async (options?: ParseConfigOptions) => {
|
|
|
37
39
|
|
|
38
40
|
const findConfigFile = async (cwd = process.cwd()) => {
|
|
39
41
|
const files = await fs.readdir(cwd)
|
|
40
|
-
const configFile = files.find((f) =>
|
|
41
|
-
|
|
42
|
+
const configFile = files.find((f) =>
|
|
43
|
+
['fab.config.js', 'fab.config.cjs', 'fab.config.mjs', 'fabrc.json', '.fabrc'].includes(f)
|
|
44
|
+
)
|
|
45
|
+
return configFile && (await readConfigFile(path.resolve(cwd, configFile)))
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
const readConfigFile = async (configPath: string): Promise<unknown> => {
|
|
45
|
-
if(/.+\.(js|cjs|mjs)$/.test(configPath)) {
|
|
49
|
+
if (/.+\.(js|cjs|mjs)$/.test(configPath)) {
|
|
46
50
|
return (await import(configPath)).default
|
|
47
51
|
}
|
|
48
|
-
if(configPath.endsWith('.json') || configPath.split('/').pop() === '.fabrc') {
|
|
52
|
+
if (configPath.endsWith('.json') || configPath.split('/').pop() === '.fabrc') {
|
|
49
53
|
return JSON.parse(await fs.readFile(configPath, 'utf-8'))
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
throw new Error(`Unable to read the config file at ${configPath}`)
|
|
53
|
-
}
|
|
57
|
+
}
|
package/src/create.ts
CHANGED
|
@@ -10,21 +10,29 @@ interface CreateOptions {
|
|
|
10
10
|
dangerouslyRewrite?: boolean
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const create = async ({
|
|
13
|
+
export const create = async ({
|
|
14
|
+
template,
|
|
15
|
+
name,
|
|
16
|
+
destination: providedDestination,
|
|
17
|
+
cwd: providedCwd,
|
|
18
|
+
dangerouslyRewrite
|
|
19
|
+
}: CreateOptions) => {
|
|
14
20
|
const cwd = providedCwd ?? process.cwd()
|
|
15
21
|
const destination = providedDestination ? path.resolve(cwd, providedDestination) : cwd
|
|
16
22
|
const finalDestination = path.resolve(destination, name)
|
|
17
23
|
// Make sure we don't overwite stuff
|
|
18
24
|
try {
|
|
19
|
-
if(
|
|
20
|
-
if(!dangerouslyRewrite) {
|
|
21
|
-
console.log(
|
|
25
|
+
if (await fs.stat(finalDestination)) {
|
|
26
|
+
if (!dangerouslyRewrite) {
|
|
27
|
+
console.log(
|
|
28
|
+
`🚨 Cannot create the pacakge at ${finalDestination}. Please delete the previous file or directory or use "dangerouslyRewrite"`
|
|
29
|
+
)
|
|
22
30
|
process.exit(1)
|
|
23
31
|
} else {
|
|
24
32
|
await deleteAsync(finalDestination)
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
|
-
} catch(e) {
|
|
35
|
+
} catch (e) {
|
|
28
36
|
// Nothing to do
|
|
29
37
|
}
|
|
30
38
|
|
|
@@ -34,13 +42,13 @@ export const create = async ({ template, name, destination: providedDestination,
|
|
|
34
42
|
const templatePath = path.resolve(getBaseDir(), `templates/${template}`)
|
|
35
43
|
|
|
36
44
|
// Make sure the template exists
|
|
37
|
-
if(!(await fs.stat(templatePath)).isDirectory()) {
|
|
45
|
+
if (!(await fs.stat(templatePath)).isDirectory()) {
|
|
38
46
|
throw new Error(`The template ${template} doesn't exist`)
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
// First, copy the template into the destintion
|
|
42
50
|
await fs.cp(templatePath, finalDestination, {
|
|
43
|
-
recursive: true
|
|
51
|
+
recursive: true
|
|
44
52
|
})
|
|
45
53
|
|
|
46
54
|
// Now we insert the name into the package file
|
|
@@ -51,10 +59,10 @@ export const create = async ({ template, name, destination: providedDestination,
|
|
|
51
59
|
|
|
52
60
|
const replaceInFile = async (filePath: string, replacements: Record<string, string>) => {
|
|
53
61
|
// Load the file
|
|
54
|
-
const content = await fs.readFile(filePath,
|
|
62
|
+
const content = await fs.readFile(filePath, 'utf-8')
|
|
55
63
|
|
|
56
64
|
// No time to build the regex and replace logic, that's for later, we just replace the name now
|
|
57
65
|
const newContent = content.replace('{{name}}', replacements.name)
|
|
58
66
|
|
|
59
67
|
await fs.writeFile(filePath, newContent)
|
|
60
|
-
}
|
|
68
|
+
}
|
package/src/types.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -76,10 +76,9 @@ export const getBaseDir = () => {
|
|
|
76
76
|
return path.resolve(path.dirname(decodeURIComponent(new URL(import.meta.url).pathname)), '..')
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export const getDefaultOptions = (): Required<BaseOptions> & Config =>
|
|
80
|
-
(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})
|
|
79
|
+
export const getDefaultOptions = (): Required<BaseOptions> & Config => ({
|
|
80
|
+
cwd: process.cwd(),
|
|
81
|
+
destination: 'dist',
|
|
82
|
+
doNotCleanup: ['src', 'bin'],
|
|
83
|
+
noCJS: false
|
|
84
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// TODO: remove this file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// TODO: remove this file
|