@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/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 (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
- )
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 (e) {
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 (!(await fs.stat(templatePath)).isDirectory()) {
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, 'utf-8')
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
@@ -1,4 +1,4 @@
1
1
  export interface BaseOptions {
2
2
  cwd?: string
3
3
  destination?: string
4
- }
4
+ }
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> & Config => ({
80
- cwd: process.cwd(),
81
- destination: 'dist',
82
- doNotCleanup: ['src', 'bin'],
83
- noCJS: false
84
- })
79
+ export const getDefaultOptions = (): Required<BaseOptions & Config> =>
80
+ ({
81
+ cwd: process.cwd(),
82
+ destination: 'dist',
83
+ doNotCleanup: ['src', 'bin']
84
+ }) as const
@@ -24,7 +24,7 @@
24
24
  "@driveflux/eslint-config": "workspace:*",
25
25
  "@driveflux/fab": "workspace:*",
26
26
  "@swc/cli": "^0.1.63",
27
- "@swc/core": "1.3.105",
27
+ "@swc/core": "^1.3.99",
28
28
  "@types/lodash": "^4.14.202",
29
29
  "@types/node": "^20.9.1",
30
30
  "del-cli": "^5.1.0",
@@ -1 +0,0 @@
1
- // TODO: remove this file
@@ -24,7 +24,7 @@
24
24
  "@driveflux/eslint-config": "workspace:*",
25
25
  "@driveflux/fab": "workspace:*",
26
26
  "@swc/cli": "^0.1.63",
27
- "@swc/core": "1.4.17",
27
+ "@swc/core": "^1.3.99",
28
28
  "@types/lodash": "^4.14.202",
29
29
  "@types/node": "^20.9.1",
30
30
  "del-cli": "^5.1.0",
@@ -1 +0,0 @@
1
- // TODO: remove this file