Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1ee7b028c | ||
|
|
0a3cbaab64 | ||
|
|
50d655a27f |
@@ -8,7 +8,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- run: npm ci
|
- run: npm install
|
||||||
- run: npm version from-git --allow-same-version --no-git-tag-version
|
- run: npm version from-git --allow-same-version --no-git-tag-version
|
||||||
- run: npm config set registry https://gitea.sugoidogo.com/api/packages/sugoidogo/npm/
|
- run: npm config set registry https://gitea.sugoidogo.com/api/packages/sugoidogo/npm/
|
||||||
- run: npm config set -- '//gitea.sugoidogo.com/api/packages/sugoidogo/npm/:_authToken' "$PACKAGES_KEY"
|
- run: npm config set -- '//gitea.sugoidogo.com/api/packages/sugoidogo/npm/:_authToken' "$PACKAGES_KEY"
|
||||||
|
|||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
*.tgz
|
*.tgz
|
||||||
|
deno.lock
|
||||||
|
package-lock.json
|
||||||
Generated
-27
@@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "node-web-globals",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"dependencies": {
|
|
||||||
"@types/node": "^25.0.9"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/node": {
|
|
||||||
"version": "25.0.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.9.tgz",
|
|
||||||
"integrity": "sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"undici-types": "~7.16.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/undici-types": {
|
|
||||||
"version": "7.16.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
|
|
||||||
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prepack": "node src/main.ts"
|
"prepack": "node src/main.ts"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"undici-types": "^7.21.0"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^25.0.9"
|
"@types/node": "^25.0.9"
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-9
@@ -1,12 +1,42 @@
|
|||||||
import * as fs from 'node:fs'
|
import * as fs from 'node:fs'
|
||||||
|
import * as path from 'node:path'
|
||||||
|
|
||||||
fs.cpSync('node_modules/@types/node/web-globals','dist',{recursive:true})
|
const sourceDir = 'node_modules/@types/node/'
|
||||||
fs.cpSync('node_modules/@types/node/LICENSE', 'LICENSE')
|
const importRegex = /import .+? from "(?:node\:)?(.+?)"/g
|
||||||
const node_types_index = fs.readFileSync('node_modules/@types/node/index.d.ts').toString()
|
|
||||||
let globals_types_index = ''
|
if (fs.existsSync('dist')) fs.rmSync('dist', { 'recursive': true })
|
||||||
for (const line of node_types_index.split('\n')) {
|
|
||||||
if (line.includes('path="web-globals/')) {
|
let imports=new Set<string>()
|
||||||
globals_types_index+=line.replace('path="web-globals/','path="')+'\n'
|
for (const basename of fs.readdirSync(sourceDir + 'web-globals/')) {
|
||||||
}
|
imports.add('web-globals/'+basename.split('.')[0])
|
||||||
}
|
}
|
||||||
fs.writeFileSync('dist/index.d.ts',globals_types_index)
|
|
||||||
|
let startSize=0
|
||||||
|
do {
|
||||||
|
startSize = imports.size
|
||||||
|
let buffer = ''
|
||||||
|
for (const importName of imports) {
|
||||||
|
if (!fs.existsSync(sourceDir + importName + '.d.ts')) {
|
||||||
|
console.warn(importName + ' is not in sources, ignoring')
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
buffer+=fs.readFileSync(sourceDir+importName+'.d.ts')
|
||||||
|
}
|
||||||
|
for (const match of buffer.matchAll(importRegex)) {
|
||||||
|
imports.add(match[1])
|
||||||
|
}
|
||||||
|
} while (startSize != imports.size)
|
||||||
|
|
||||||
|
let index = ''
|
||||||
|
for (const importName of imports) {
|
||||||
|
if (!fs.existsSync(sourceDir + importName + '.d.ts')) {
|
||||||
|
console.warn(importName + ' is not in sources, ignoring')
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fs.mkdirSync(path.dirname('dist/'+importName+'.d.ts'),{'recursive':true})
|
||||||
|
fs.copyFileSync(sourceDir + importName + '.d.ts', 'dist/' + importName + '.d.ts')
|
||||||
|
index += `/// <reference path="${importName}.d.ts" />\n`
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync('dist/index.d.ts',index)
|
||||||
|
fs.cpSync('node_modules/@types/node/LICENSE', 'LICENSE')
|
||||||
+4
-1
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"target": "esnext",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"moduleResolution": "node"
|
"moduleResolution": "node",
|
||||||
|
"lib": ["ESNext"],
|
||||||
|
"types": ["node"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user