@xyo-network/sdk-js 3.14.12 → 3.14.13
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/package.json +8 -9
- package/scripts/deplint.mjs +116 -0
- package/scripts/imports.mjs +0 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/sdk-js",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.13",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -39,14 +39,11 @@
|
|
|
39
39
|
"compile": "./scripts/clear-scrollback-buffer.sh && yarn xy compile",
|
|
40
40
|
"coverage": "vitest --coverage --watch false",
|
|
41
41
|
"cycle": "node ./scripts/run-cycle.mjs",
|
|
42
|
-
"
|
|
42
|
+
"deplint": "node ./scripts/deplint.mjs",
|
|
43
43
|
"deploy": "xy deploy",
|
|
44
44
|
"free-3033": "kill -9 $(lsof -t -i :3033)",
|
|
45
45
|
"free-8080": "kill -9 $(lsof -t -i :8080)",
|
|
46
46
|
"free-mongo": "kill -9 $(lsof -t -i :55391) && kill -9 $(lsof -t -i :55393)",
|
|
47
|
-
"knip:modules": "echo ---Unlisted Dependencies--- && yarn workspace @xyo-network/modules run knip --include unlisted --no-exit-code",
|
|
48
|
-
"knip:unlisted": "echo ---Unlisted Dependencies--- && yarn workspaces foreach -Ap --exclude @xyo-network/sdk-js --no-interlaced run knip --include unlisted",
|
|
49
|
-
"knip:wallet": "echo ---Unlisted Dependencies--- && yarn workspace @xyo-network/wallet run knip --include unlisted --no-exit-code",
|
|
50
47
|
"package-build": "yarn package-clean && rimraf docs && yarn package-build-only && typedoc && xy statics",
|
|
51
48
|
"package-clean": "rimraf dist",
|
|
52
49
|
"test": "vitest --watch false"
|
|
@@ -57,9 +54,9 @@
|
|
|
57
54
|
"unrs-resolver": "1.7.0"
|
|
58
55
|
},
|
|
59
56
|
"dependencies": {
|
|
60
|
-
"@xyo-network/manifest": "^3.14.
|
|
61
|
-
"@xyo-network/modules": "^3.14.
|
|
62
|
-
"@xyo-network/protocol": "^3.14.
|
|
57
|
+
"@xyo-network/manifest": "^3.14.13",
|
|
58
|
+
"@xyo-network/modules": "^3.14.13",
|
|
59
|
+
"@xyo-network/protocol": "^3.14.13"
|
|
63
60
|
},
|
|
64
61
|
"devDependencies": {
|
|
65
62
|
"@firebase/app": "^0.11.5",
|
|
@@ -74,11 +71,13 @@
|
|
|
74
71
|
"@xylabs/ts-scripts-yarn3": "^6.3.5",
|
|
75
72
|
"@xylabs/tsconfig": "^6.3.5",
|
|
76
73
|
"@xylabs/vitest-extended": "^4.8.7",
|
|
77
|
-
"@xyo-network/sdk-utils": "^3.14.
|
|
74
|
+
"@xyo-network/sdk-utils": "^3.14.13",
|
|
75
|
+
"chalk": "^5.4.1",
|
|
78
76
|
"dependency-cruiser": "^16.10.1",
|
|
79
77
|
"dotenv": "^16.5.0",
|
|
80
78
|
"eslint": "^9.25.1",
|
|
81
79
|
"eslint-import-resolver-typescript": "^4.3.4",
|
|
80
|
+
"glob": "^11.0.2",
|
|
82
81
|
"jsdom": "^26.1.0",
|
|
83
82
|
"knip": "^5.50.5",
|
|
84
83
|
"reflect-metadata": "^0.2.2",
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import ts from 'typescript'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import fs from 'node:fs'
|
|
6
|
+
import { globSync } from 'glob'
|
|
7
|
+
import { yarnWorkspaces } from '@xylabs/ts-scripts-yarn3'
|
|
8
|
+
import chalk from 'chalk'
|
|
9
|
+
|
|
10
|
+
function getDependenciesFromPackageJson(packageJsonPath) {
|
|
11
|
+
const packageJsonFullPath = path.resolve(packageJsonPath)
|
|
12
|
+
const rawContent = fs.readFileSync(packageJsonFullPath, 'utf8')
|
|
13
|
+
const packageJson = JSON.parse(rawContent)
|
|
14
|
+
|
|
15
|
+
const dependencies = packageJson.dependencies
|
|
16
|
+
? Object.keys(packageJson.dependencies)
|
|
17
|
+
: []
|
|
18
|
+
|
|
19
|
+
const devDependencies = packageJson.devDependencies
|
|
20
|
+
? Object.keys(packageJson.devDependencies)
|
|
21
|
+
: []
|
|
22
|
+
|
|
23
|
+
return { dependencies, devDependencies }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getBasePackageName(importName) {
|
|
27
|
+
if (importName.startsWith('@')) {
|
|
28
|
+
const parts = importName.split('/')
|
|
29
|
+
return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : importName
|
|
30
|
+
}
|
|
31
|
+
return importName.split('/')[0]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getImportsFromFile(filePath, importPaths) {
|
|
35
|
+
const sourceCode = fs.readFileSync(filePath, 'utf8')
|
|
36
|
+
|
|
37
|
+
const sourceFile = ts.createSourceFile(
|
|
38
|
+
path.basename(filePath),
|
|
39
|
+
sourceCode,
|
|
40
|
+
ts.ScriptTarget.Latest,
|
|
41
|
+
true,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const imports = []
|
|
45
|
+
|
|
46
|
+
function visit(node) {
|
|
47
|
+
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
48
|
+
const moduleSpecifier = (node.moduleSpecifier)?.text
|
|
49
|
+
if (moduleSpecifier) {
|
|
50
|
+
imports.push(moduleSpecifier)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
ts.forEachChild(node, visit)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
visit(sourceFile)
|
|
57
|
+
|
|
58
|
+
const cleanedImports = imports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:')).map(getBasePackageName)
|
|
59
|
+
|
|
60
|
+
for (const imp of cleanedImports) {
|
|
61
|
+
importPaths[imp] = importPaths[imp] || []
|
|
62
|
+
importPaths[imp].push(filePath)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return cleanedImports
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function findFilesByGlob(cwd, pattern) {
|
|
69
|
+
return globSync(pattern, { cwd, absolute: true })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function run({
|
|
73
|
+
name, location, devDeps = false,
|
|
74
|
+
}) {
|
|
75
|
+
const allFiles = findFilesByGlob(location, './src/**/*.{ts,tsx}')
|
|
76
|
+
const prodFiles = allFiles.filter(file => !file.endsWith('.spec.ts') && !file.endsWith('.stories.tsx') && !file.includes('/spec/'))
|
|
77
|
+
const devFiles = allFiles.filter(file => file.endsWith('.spec.ts') || file.endsWith('.stories.tsx') || file.includes('/spec/'))
|
|
78
|
+
// console.log('Production files:', prodFiles)
|
|
79
|
+
// console.log('Development files:', devFiles)
|
|
80
|
+
const prodImportPaths = {}
|
|
81
|
+
const prodImports = prodFiles.flatMap(path => getImportsFromFile(path, prodImportPaths))
|
|
82
|
+
const devImportPaths = {}
|
|
83
|
+
const devImports = devFiles.flatMap(path => getImportsFromFile(path, devImportPaths))
|
|
84
|
+
const externalProdImports = prodImports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:'))
|
|
85
|
+
const externalDevImports = devImports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:'))
|
|
86
|
+
|
|
87
|
+
// console.log('externalProdImports:', externalProdImports)
|
|
88
|
+
// console.log('externalDevImports:', externalDevImports)
|
|
89
|
+
|
|
90
|
+
const deps = getDependenciesFromPackageJson(`${location}/package.json`)
|
|
91
|
+
// console.log('Project.Dependencies:', deps.dependencies)
|
|
92
|
+
// console.log('Project.DevDependencies:', deps.devDependencies)
|
|
93
|
+
|
|
94
|
+
for (const imp of externalProdImports) {
|
|
95
|
+
if (!deps.dependencies.includes(imp)) {
|
|
96
|
+
console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)
|
|
97
|
+
console.log(` ${prodImportPaths[imp].join('\n')}`)
|
|
98
|
+
console.log('')
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (devDeps) {
|
|
103
|
+
for (const imp of externalDevImports) {
|
|
104
|
+
if (!deps.devDependencies.includes(imp)) {
|
|
105
|
+
console.log(`[${chalk.blue(name)}] Missing devDependency in package.json: ${chalk.red(imp)}`)
|
|
106
|
+
console.log(` Found in: ${devImportPaths[imp].join(', ')}`)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const workspaces = yarnWorkspaces()
|
|
113
|
+
|
|
114
|
+
for (const workspace of workspaces) {
|
|
115
|
+
run(workspace)
|
|
116
|
+
}
|
package/scripts/imports.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import ts from 'typescript'
|
|
4
|
-
import path from 'node:path'
|
|
5
|
-
import fs from 'node:fs'
|
|
6
|
-
|
|
7
|
-
function getDependenciesFromPackageJson(packageJsonPath) {
|
|
8
|
-
const packageJsonFullPath = path.resolve(packageJsonPath)
|
|
9
|
-
const rawContent = fs.readFileSync(packageJsonFullPath, 'utf8')
|
|
10
|
-
const packageJson = JSON.parse(rawContent)
|
|
11
|
-
|
|
12
|
-
const dependencies = packageJson.dependencies
|
|
13
|
-
? Object.keys(packageJson.dependencies)
|
|
14
|
-
: []
|
|
15
|
-
|
|
16
|
-
const devDependencies = packageJson.devDependencies
|
|
17
|
-
? Object.keys(packageJson.devDependencies)
|
|
18
|
-
: []
|
|
19
|
-
|
|
20
|
-
return { dependencies, devDependencies }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getImportsFromFile(filePath) {
|
|
24
|
-
const sourceCode = fs.readFileSync(filePath, 'utf8')
|
|
25
|
-
|
|
26
|
-
const sourceFile = ts.createSourceFile(
|
|
27
|
-
path.basename(filePath),
|
|
28
|
-
sourceCode,
|
|
29
|
-
ts.ScriptTarget.Latest,
|
|
30
|
-
true,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
const imports = []
|
|
34
|
-
|
|
35
|
-
function visit(node) {
|
|
36
|
-
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
37
|
-
const moduleSpecifier = (node.moduleSpecifier)?.text
|
|
38
|
-
if (moduleSpecifier) {
|
|
39
|
-
imports.push(moduleSpecifier)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
ts.forEachChild(node, visit)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
visit(sourceFile)
|
|
46
|
-
|
|
47
|
-
return imports
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function run() {
|
|
51
|
-
const imports = getImportsFromFile('./src/index.ts')
|
|
52
|
-
const externalImports = imports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#'))
|
|
53
|
-
console.log(externalImports)
|
|
54
|
-
|
|
55
|
-
const deps = getDependenciesFromPackageJson('./package.json')
|
|
56
|
-
console.log('Dependencies:', deps.dependencies)
|
|
57
|
-
console.log('DevDependencies:', deps.devDependencies)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
run()
|