@capgo/cli 4.12.2 → 4.12.3-beta.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/CHANGELOG.md +7 -0
- package/bun.lockb +0 -0
- package/dist/index.js +40 -1190
- package/package.json +1 -3
- package/src/utils.ts +33 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/cli",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.3-beta.0",
|
|
4
4
|
"description": "A CLI to upload to capgo servers",
|
|
5
5
|
"author": "github.com/riderx",
|
|
6
6
|
"license": "Apache 2.0",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"ky": "^1.3.0",
|
|
62
62
|
"logsnag": "1.0.0",
|
|
63
63
|
"mime": "^4.0.3",
|
|
64
|
-
"node-dir": "^0.1.17",
|
|
65
64
|
"open": "^10.1.0",
|
|
66
65
|
"prettyjson": "^1.2.5",
|
|
67
66
|
"semver": "^7.6.2",
|
|
@@ -72,7 +71,6 @@
|
|
|
72
71
|
"@types/adm-zip": "0.5.5",
|
|
73
72
|
"@types/mime": "^4.0.0",
|
|
74
73
|
"@types/node": "^20.14.7",
|
|
75
|
-
"@types/node-dir": "^0.0.37",
|
|
76
74
|
"@types/npmcli__ci-detect": "^2.0.3",
|
|
77
75
|
"@types/prettyjson": "^0.0.33",
|
|
78
76
|
"@types/prompt-sync": "^4.2.3",
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'
|
|
1
|
+
import { existsSync, readFileSync, readdir, readdirSync, statSync } from 'node:fs'
|
|
2
2
|
import { homedir, platform as osPlatform } from 'node:os'
|
|
3
3
|
import { join, resolve, sep } from 'node:path'
|
|
4
4
|
import process from 'node:process'
|
|
@@ -11,7 +11,6 @@ import prettyjson from 'prettyjson'
|
|
|
11
11
|
import { LogSnag } from 'logsnag'
|
|
12
12
|
import * as p from '@clack/prompts'
|
|
13
13
|
import ky from 'ky'
|
|
14
|
-
import { promiseFiles } from 'node-dir'
|
|
15
14
|
import { findRootSync } from '@manypkg/find-root'
|
|
16
15
|
import type { InstallCommand, PackageManagerRunner, PackageManagerType } from '@capgo/find-package-manager'
|
|
17
16
|
import { findInstallCommand, findPackageManagerRunner, findPackageManagerType } from '@capgo/find-package-manager'
|
|
@@ -840,16 +839,33 @@ export function getPMAndCommand() {
|
|
|
840
839
|
return { pm, command: pmCommand, installCommand: `${pm} ${pmCommand}`, runner: pmRunner }
|
|
841
840
|
}
|
|
842
841
|
|
|
842
|
+
function readDirRecursively(dir: string): string[] {
|
|
843
|
+
const entries = readdirSync(dir, { withFileTypes: true })
|
|
844
|
+
const files = entries.flatMap((entry) => {
|
|
845
|
+
const fullPath = join(dir, entry.name)
|
|
846
|
+
if (entry.isDirectory()) {
|
|
847
|
+
return readDirRecursively(fullPath)
|
|
848
|
+
}
|
|
849
|
+
else {
|
|
850
|
+
// Use relative path to avoid issues with long paths on Windows
|
|
851
|
+
return fullPath.split(`node_modules${sep}`)[1] || fullPath
|
|
852
|
+
}
|
|
853
|
+
})
|
|
854
|
+
return files
|
|
855
|
+
}
|
|
856
|
+
|
|
843
857
|
export async function getLocalDepenencies() {
|
|
844
858
|
const dir = findRootSync(process.cwd())
|
|
845
|
-
|
|
859
|
+
const packageJsonPath = join(process.cwd(), 'package.json')
|
|
860
|
+
|
|
861
|
+
if (!existsSync(packageJsonPath)) {
|
|
846
862
|
p.log.error('Missing package.json, you need to be in a capacitor project')
|
|
847
863
|
program.error('')
|
|
848
864
|
}
|
|
849
865
|
|
|
850
866
|
let packageJson
|
|
851
867
|
try {
|
|
852
|
-
packageJson = JSON.parse(readFileSync(
|
|
868
|
+
packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
|
|
853
869
|
}
|
|
854
870
|
catch (err) {
|
|
855
871
|
p.log.error('Invalid package.json, JSON parsing failed')
|
|
@@ -870,7 +886,8 @@ export async function getLocalDepenencies() {
|
|
|
870
886
|
}
|
|
871
887
|
}
|
|
872
888
|
|
|
873
|
-
|
|
889
|
+
const nodeModulesPath = join(process.cwd(), 'node_modules')
|
|
890
|
+
if (!existsSync(nodeModulesPath)) {
|
|
874
891
|
const pm = findPackageManagerType(dir.rootDir, 'npm')
|
|
875
892
|
const installCmd = findInstallCommand(pm)
|
|
876
893
|
p.log.error(`Missing node_modules folder, please run ${pm} ${installCmd}`)
|
|
@@ -880,9 +897,9 @@ export async function getLocalDepenencies() {
|
|
|
880
897
|
let anyInvalid = false
|
|
881
898
|
|
|
882
899
|
const dependenciesObject = await Promise.all(Object.entries(dependencies as Record<string, string>)
|
|
883
|
-
|
|
884
900
|
.map(async ([key, value]) => {
|
|
885
|
-
const
|
|
901
|
+
const dependencyFolderPath = join(nodeModulesPath, key)
|
|
902
|
+
const dependencyFolderExists = existsSync(dependencyFolderPath)
|
|
886
903
|
|
|
887
904
|
if (!dependencyFolderExists) {
|
|
888
905
|
anyInvalid = true
|
|
@@ -893,16 +910,15 @@ export async function getLocalDepenencies() {
|
|
|
893
910
|
}
|
|
894
911
|
|
|
895
912
|
let hasNativeFiles = false
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
.
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
})
|
|
913
|
+
try {
|
|
914
|
+
const files = readDirRecursively(dependencyFolderPath)
|
|
915
|
+
hasNativeFiles = files.some(fileName => nativeFileRegex.test(fileName))
|
|
916
|
+
}
|
|
917
|
+
catch (error) {
|
|
918
|
+
p.log.error(`Error reading node_modules files for ${key} package`)
|
|
919
|
+
console.error(error)
|
|
920
|
+
program.error('')
|
|
921
|
+
}
|
|
906
922
|
|
|
907
923
|
return {
|
|
908
924
|
name: key,
|