Skip to content

Commit 38d2f40

Browse files
committed
[TASK] update deps, refactor
1 parent 388ad7a commit 38d2f40

6 files changed

Lines changed: 306 additions & 3620 deletions

File tree

lib/arg/debug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import chalk from 'chalk'
22
import dotenv from 'dotenv'
3-
import { isFileDir } from '@resultify/hubspot-tools-theme-lib/lib/utils/fs.js'
3+
import { isFileDir } from '../utils/fs.js'
44

55
/**
66
* @summary Get .env config

lib/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { checkNode } from '@resultify/hubspot-tools-theme-lib/lib/utils/check.js'
1+
// import { checkNode } from '@resultify/hubspot-cms-lib/lib/utils/check.js'
22
import { parseArgs, checkIfMoreThanOneArg } from './arg/arg.js'
33
import { localstorage } from './local-storage.js'
44
import { showInfo as info } from './cmd/info.js'
@@ -10,7 +10,7 @@ await checkIfSsh()
1010
await checkIfBinExists('git')
1111
await checkIfBinExists('node')
1212
await checkIfBinExists('npm')
13-
checkNode()
13+
// checkNode()
1414

1515
// cli data localstorage
1616
let data = await localstorage()

lib/local-storage.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,5 @@
11
import { execa } from 'execa'
2-
import { isFileDir } from '@resultify/hubspot-tools-theme-lib/lib/utils/fs.js'
3-
import { createRequire } from 'module'
4-
const require = createRequire(import.meta.url)
5-
6-
/**
7-
* @summary Import theme.json
8-
* @async
9-
* @private
10-
* @returns {Promise<Object|boolean>} theme.json|false
11-
*/
12-
async function importThemeJson () {
13-
if (await isFileDir(`${process.cwd()}/theme/theme.json`)) {
14-
return require(`${process.cwd()}/theme/theme.json`)
15-
} else {
16-
return false
17-
}
18-
}
19-
20-
/**
21-
* @summary Import package.json
22-
* @async
23-
* @private
24-
* @returns {Promise<Object|boolean>} package.json|false
25-
*/
26-
async function importPackageJson () {
27-
if (await isFileDir(`${process.cwd()}/package.json`)) {
28-
return require(`${process.cwd()}/package.json`)
29-
} else {
30-
return false
31-
}
32-
}
2+
import { importThemeJson, importPackageJson } from './utils/fs.js'
333

344
/**
355
* @summary data locals torage

lib/utils/fs.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import fsPromises from 'fs/promises'
2+
import { createRequire } from 'module'
3+
const require = createRequire(import.meta.url)
4+
5+
/**
6+
* @summary check if file/dir exists
7+
* @async
8+
* @param {string} path - file/dir path
9+
* @returns {Promise<boolean>}
10+
*/
11+
async function isFileDir (path) {
12+
try {
13+
await fsPromises.stat(path)
14+
return true
15+
} catch (error) {
16+
if (error.code === 'ENOENT') {
17+
return false
18+
}
19+
console.error(error)
20+
}
21+
}
22+
23+
/**
24+
* @summary Import theme.json
25+
* @async
26+
* @private
27+
* @returns {Promise<Object|boolean>} theme.json|false
28+
*/
29+
async function importThemeJson () {
30+
if (await isFileDir(`${process.cwd()}/theme/theme.json`)) {
31+
return require(`${process.cwd()}/theme/theme.json`)
32+
} else {
33+
return false
34+
}
35+
}
36+
37+
/**
38+
* @summary Import package.json
39+
* @async
40+
* @private
41+
* @returns {Promise<Object|boolean>} package.json|false
42+
*/
43+
async function importPackageJson () {
44+
if (await isFileDir(`${process.cwd()}/package.json`)) {
45+
return require(`${process.cwd()}/package.json`)
46+
} else {
47+
return false
48+
}
49+
}
50+
51+
export { importPackageJson, importThemeJson, isFileDir }

0 commit comments

Comments
 (0)