@driveflux/fab 1.0.9 → 2.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/.turbo/turbo-build.log +13 -16
- package/CHANGELOG.md +1 -80
- package/bin/fab.js +6 -7
- package/dist/build.d.ts +5 -7
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +79 -166
- package/dist/clean.d.ts.map +1 -1
- package/dist/clean.js +17 -17
- package/dist/config.d.ts +0 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -13
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +8 -8
- package/dist/index.js +5 -5
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +21 -22
- package/package.json +11 -14
- package/src/build.ts +73 -119
- package/src/clean.ts +4 -8
- package/src/config.ts +12 -18
- package/src/create.ts +9 -17
- package/src/types.ts +1 -1
- package/src/utils.ts +6 -6
- package/templates/backend/package.json +1 -1
- package/templates/backend/src/index.ts +0 -1
- package/templates/frontend/package.json +1 -1
- package/templates/frontend/src/index.ts +0 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/create.ts
CHANGED
|
@@ -10,29 +10,21 @@ interface CreateOptions {
|
|
|
10
10
|
dangerouslyRewrite?: boolean
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const create = async ({
|
|
14
|
-
template,
|
|
15
|
-
name,
|
|
16
|
-
destination: providedDestination,
|
|
17
|
-
cwd: providedCwd,
|
|
18
|
-
dangerouslyRewrite
|
|
19
|
-
}: CreateOptions) => {
|
|
13
|
+
export const create = async ({ template, name, destination: providedDestination, cwd: providedCwd, dangerouslyRewrite }: CreateOptions) => {
|
|
20
14
|
const cwd = providedCwd ?? process.cwd()
|
|
21
15
|
const destination = providedDestination ? path.resolve(cwd, providedDestination) : cwd
|
|
22
16
|
const finalDestination = path.resolve(destination, name)
|
|
23
17
|
// Make sure we don't overwite stuff
|
|
24
18
|
try {
|
|
25
|
-
if
|
|
26
|
-
if
|
|
27
|
-
console.log(
|
|
28
|
-
`🚨 Cannot create the pacakge at ${finalDestination}. Please delete the previous file or directory or use "dangerouslyRewrite"`
|
|
29
|
-
)
|
|
19
|
+
if((await fs.stat(finalDestination))) {
|
|
20
|
+
if(!dangerouslyRewrite) {
|
|
21
|
+
console.log(`🚨 Cannot create the pacakge at ${finalDestination}. Please delete the previous file or directory or use "dangerouslyRewrite"`)
|
|
30
22
|
process.exit(1)
|
|
31
23
|
} else {
|
|
32
24
|
await deleteAsync(finalDestination)
|
|
33
25
|
}
|
|
34
26
|
}
|
|
35
|
-
} catch
|
|
27
|
+
} catch(e) {
|
|
36
28
|
// Nothing to do
|
|
37
29
|
}
|
|
38
30
|
|
|
@@ -42,13 +34,13 @@ export const create = async ({
|
|
|
42
34
|
const templatePath = path.resolve(getBaseDir(), `templates/${template}`)
|
|
43
35
|
|
|
44
36
|
// Make sure the template exists
|
|
45
|
-
if
|
|
37
|
+
if(!(await fs.stat(templatePath)).isDirectory()) {
|
|
46
38
|
throw new Error(`The template ${template} doesn't exist`)
|
|
47
39
|
}
|
|
48
40
|
|
|
49
41
|
// First, copy the template into the destintion
|
|
50
42
|
await fs.cp(templatePath, finalDestination, {
|
|
51
|
-
recursive: true
|
|
43
|
+
recursive: true,
|
|
52
44
|
})
|
|
53
45
|
|
|
54
46
|
// Now we insert the name into the package file
|
|
@@ -59,10 +51,10 @@ export const create = async ({
|
|
|
59
51
|
|
|
60
52
|
const replaceInFile = async (filePath: string, replacements: Record<string, string>) => {
|
|
61
53
|
// Load the file
|
|
62
|
-
const content = await fs.readFile(filePath,
|
|
54
|
+
const content = await fs.readFile(filePath, 'utf-8')
|
|
63
55
|
|
|
64
56
|
// No time to build the regex and replace logic, that's for later, we just replace the name now
|
|
65
57
|
const newContent = content.replace('{{name}}', replacements.name)
|
|
66
58
|
|
|
67
59
|
await fs.writeFile(filePath, newContent)
|
|
68
|
-
}
|
|
60
|
+
}
|
package/src/types.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -76,9 +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
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
})
|
|
79
|
+
export const getDefaultOptions = (): Required<BaseOptions & Config> =>
|
|
80
|
+
({
|
|
81
|
+
cwd: process.cwd(),
|
|
82
|
+
destination: 'dist',
|
|
83
|
+
doNotCleanup: ['src', 'bin']
|
|
84
|
+
}) as const
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// TODO: remove this file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// TODO: remove this file
|