Skip to content

Commit ac969e7

Browse files
authored
Fix yarn package, and remove problematic glob dependency. (#574)
1 parent 2e0b2cc commit ac969e7

File tree

3 files changed

+16
-62
lines changed

3 files changed

+16
-62
lines changed

src/rpc/client/ts/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
"package-create": "node -e \"require('./scripts/package.ts').create()\"",
2626
"pretest": "yarn prepackage",
2727
"test": "mocha --exit --timeout 50000 --slow 10000 --require ts-node/register --require tests/fixtures.ts --exclude ./tests/specs/server.spec.ts ./tests/specs/*.spec.ts && mocha --exit --timeout 10000 --slow 1000 --require ts-node/register ./tests/specs/server.spec.ts",
28-
"lint": "yarn prettier --check src tests",
29-
"lint:fix": "yarn prettier --write src tests"
28+
"lint": "yarn prettier --check scripts src tests",
29+
"lint:fix": "yarn prettier --write scripts src tests"
3030
},
3131
"devDependencies": {
3232
"@types/chai": "^4.3.1",
3333
"@types/mocha": "^10.0.0",
3434
"chai": "^4.3.6",
35-
"glob": "^9.2.1",
3635
"grpc-tools": "^1.12.4",
3736
"grpc_tools_node_protoc_ts": "^5.3.3",
3837
"mocha": "^10.0.0",

src/rpc/client/ts/scripts/package.ts

+12-34
Original file line numberDiff line numberDiff line change
@@ -21,65 +21,43 @@
2121
// but with some TypeScript niceness baked in
2222
const fs = require('fs')
2323
const path = require('path')
24-
const glob = require('glob')
2524
const execSync = require('child_process').execSync
2625
const pkg_dir = 'dist/package'
2726
const pkg_version = JSON.parse(fs.readFileSync('./package.json').toString())[
2827
'version'
2928
]
3029

31-
function copyDirectory(srcDir, destDir) {
30+
function copyFiles(srcDir, destDir, extension = '') {
3231
// Ensure that the destination directory exists
3332
if (!fs.existsSync(destDir)) {
3433
fs.mkdirSync(destDir, { recursive: true })
3534
}
3635

37-
// Loop through each file or directory
38-
fs.readdirSync(srcDir, { withFileTypes: true }).forEach((file) => {
39-
// Construct the full path of the file or directory
40-
const srcPath = path.join(srcDir, file.name)
41-
const destPath = path.join(destDir, file.name)
36+
fs.readdirSync(srcDir).forEach((file) => {
37+
const srcPath = path.join(srcDir, file)
38+
const destPath = path.join(destDir, file)
4239

43-
if (file.isDirectory()) {
44-
// If the file is a directory, recursively call this function on the directory
45-
copyDirectory(srcPath, destPath)
46-
} else {
47-
// If the file is a file, copy it to the destination directory
40+
if (fs.statSync(srcPath).isDirectory()) {
41+
copyFiles(srcPath, destPath, extension)
42+
} else if (extension.length === 0 || file.endsWith(extension)) {
4843
fs.copyFileSync(srcPath, destPath)
4944
}
5045
})
5146
}
5247

53-
function copyGlob(pattern, destDir = pkg_dir, dir = '.') {
54-
glob(pattern, { cwd: dir }, (error, files) => {
55-
for (let i = 0; i < files.length; i++) {
56-
const src = path.join(dir, files[i])
57-
const dst = path.join(destDir, path.parse(files[i]).base)
58-
const dstDir = path.dirname(dst)
59-
60-
fs.mkdirSync(dstDir, { recursive: true })
61-
62-
if (fs.statSync(src).isFile()) {
63-
fs.copyFileSync(src, dst)
64-
}
65-
}
66-
})
67-
}
68-
6948
// Setup package directory
7049
function setup() {
7150
if (fs.existsSync(pkg_dir)) {
7251
fs.rmSync(pkg_dir, { recursive: true, force: true })
7352
}
7453

75-
fs.mkdirSync(pkg_dir, { recursive: true })
76-
77-
copyGlob(path.join('src', '*.d.ts'))
78-
copyGlob(path.join('src', '*.js'))
79-
copyGlob(path.join('out', '*'))
54+
// Copy generated files to the package directory
55+
copyFiles('src', pkg_dir, '.d.ts')
56+
copyFiles('src', pkg_dir, '.js')
57+
copyFiles('out', pkg_dir)
8058

8159
// Copy the server directory to the package directory
82-
copyDirectory(
60+
copyFiles(
8361
`omega-edit-grpc-server-${pkg_version}`,
8462
path.join(pkg_dir, `omega-edit-grpc-server-${pkg_version}`)
8563
)

src/rpc/client/ts/yarn.lock

+2-25
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,6 @@ glob@^7.1.3:
560560
once "^1.3.0"
561561
path-is-absolute "^1.0.0"
562562

563-
glob@^9.2.1:
564-
version "9.2.1"
565-
resolved "https://registry.yarnpkg.com/glob/-/glob-9.2.1.tgz#f47e34e1119e7d4f93a546e75851ba1f1e68de50"
566-
integrity sha512-Pxxgq3W0HyA3XUvSXcFhRSs+43Jsx0ddxcFrbjxNGkL2Ak5BAUBxLqI5G6ADDeCHLfzzXFhe0b1yYcctGmytMA==
567-
dependencies:
568-
fs.realpath "^1.0.0"
569-
minimatch "^7.4.1"
570-
minipass "^4.2.4"
571-
path-scurry "^1.6.1"
572-
573563
574564
version "3.15.8"
575565
resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.15.8.tgz#5f3948905e4951c867d6bc143f385a80e2a39efe"
@@ -743,11 +733,6 @@ lru-cache@^6.0.0:
743733
dependencies:
744734
yallist "^4.0.0"
745735

746-
lru-cache@^7.14.1:
747-
version "7.18.3"
748-
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.18.3.tgz#f793896e0fd0e954a59dfdd82f0773808df6aa89"
749-
integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==
750-
751736
lunr@^2.3.9:
752737
version "2.3.9"
753738
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
@@ -784,7 +769,7 @@ minimatch@^3.0.4, minimatch@^3.1.1:
784769
dependencies:
785770
brace-expansion "^1.1.7"
786771

787-
minimatch@^7.1.3, minimatch@^7.4.1:
772+
minimatch@^7.1.3:
788773
version "7.4.2"
789774
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-7.4.2.tgz#157e847d79ca671054253b840656720cb733f10f"
790775
integrity sha512-xy4q7wou3vUoC9k1xGTXc+awNdGaGVHtFUaey8tiX4H1QRc04DZ/rmDFwNm2EBsuYEhAZ6SgMmYf3InGY6OauA==
@@ -803,7 +788,7 @@ minipass@^3.0.0:
803788
dependencies:
804789
yallist "^4.0.0"
805790

806-
minipass@^4.0.0, minipass@^4.0.2, minipass@^4.2.4:
791+
minipass@^4.0.0:
807792
version "4.2.4"
808793
resolved "https://registry.yarnpkg.com/minipass/-/minipass-4.2.4.tgz#7d0d97434b6a19f59c5c3221698b48bbf3b2cd06"
809794
integrity sha512-lwycX3cBMTvcejsHITUgYj6Gy6A7Nh4Q6h9NP4sTHY1ccJlC7yKzDmiShEHsJ16Jf1nKGDEaiHxiltsJEvk0nQ==
@@ -938,14 +923,6 @@ path-is-absolute@^1.0.0:
938923
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
939924
integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==
940925

941-
path-scurry@^1.6.1:
942-
version "1.6.1"
943-
resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.6.1.tgz#dab45f7bb1d3f45a0e271ab258999f4ab7e23132"
944-
integrity sha512-OW+5s+7cw6253Q4E+8qQ/u1fVvcJQCJo/VFD8pje+dbJCF1n5ZRMV2AEHbGp+5Q7jxQIYJxkHopnj6nzdGeZLA==
945-
dependencies:
946-
lru-cache "^7.14.1"
947-
minipass "^4.0.2"
948-
949926
pathval@^1.1.1:
950927
version "1.1.1"
951928
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d"

0 commit comments

Comments
 (0)