-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
281 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ debug/ | |
# deno project file | ||
settings.json | ||
|
||
deno.lock | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
coverage/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env -S deno run -A | ||
/* | ||
* Copyright 2021-2024 The NATS Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { parseArgs } from "jsr:@std/cli/parse-args"; | ||
import { join } from "jsr:@std/path"; | ||
|
||
async function load(fp: string): Promise<string> { | ||
const src = await Deno.readTextFile(fp); | ||
const { version } = JSON.parse(src); | ||
return version; | ||
} | ||
|
||
const argv = parseArgs( | ||
Deno.args, | ||
{ | ||
alias: { | ||
"m": ["module"], | ||
"t": ["tag"], | ||
}, | ||
string: ["module", "tag"], | ||
}, | ||
); | ||
|
||
const module = argv.module || null; | ||
|
||
if (module === null) { | ||
console.error( | ||
`[ERROR] --module is required`, | ||
); | ||
Deno.exit(1); | ||
} | ||
|
||
let version: string; | ||
|
||
if (module.startsWith("transport-")) { | ||
let packageVersion: string = ""; | ||
const versionFile = await load(join(module, "src", "version.json")); | ||
switch (module) { | ||
case "transport-node": | ||
packageVersion = await load(join(module, "package.json")); | ||
break; | ||
default: | ||
packageVersion = await load(join(module, "deno.json")); | ||
break; | ||
} | ||
if (!packageVersion) { | ||
console.error( | ||
`[ERROR] package version for module ${module} is missing a version`, | ||
); | ||
Deno.exit(1); | ||
} | ||
if (!versionFile) { | ||
console.error( | ||
`[ERROR] src/version.json file for module ${module} is missing a version`, | ||
); | ||
Deno.exit(1); | ||
} | ||
if (packageVersion !== versionFile) { | ||
console.error( | ||
`[ERROR] expected versions to match - package: ${packageVersion} src/version.json: ${versionFile}`, | ||
); | ||
Deno.exit(1); | ||
} | ||
version = versionFile; | ||
} else { | ||
const deno = await load(join(module, "deno.json")); | ||
const node = await load(join(module, "package.json")); | ||
|
||
if (deno !== node) { | ||
console.error( | ||
`[ERROR] expected versions to match - deno.json: ${deno} package.json: ${node}`, | ||
); | ||
Deno.exit(1); | ||
} | ||
version = deno; | ||
} | ||
|
||
if (argv.tag) { | ||
let tag = argv.tag; | ||
const prefix = `${argv.module}/`; | ||
if (tag.startsWith(prefix)) { | ||
tag = tag.substring(prefix.length); | ||
} | ||
if (tag !== version) { | ||
console.error( | ||
`[ERROR] expected tag version to match - bundle: ${version} tag: ${argv.tag}}`, | ||
); | ||
Deno.exit(1); | ||
} | ||
} | ||
|
||
Deno.exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/usr/bin/env -S deno run -A | ||
/* | ||
* Copyright 2021-2024 The NATS Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { parseArgs } from "jsr:@std/cli/parse-args"; | ||
import { join } from "jsr:@std/path"; | ||
|
||
async function load<T>(fp: string): Promise<T> { | ||
const src = await Deno.readTextFile(fp); | ||
return JSON.parse(src); | ||
} | ||
|
||
type denoImports = { | ||
imports: Record<string, string>; | ||
}; | ||
|
||
type nodeDependencies = { | ||
dependencies: Record<string, string>; | ||
}; | ||
|
||
const argv = parseArgs( | ||
Deno.args, | ||
{ | ||
alias: { | ||
"m": ["module"], | ||
"v": ["verbose"], | ||
"f": ["fix"], | ||
}, | ||
string: ["module"], | ||
boolean: ["v", "f"], | ||
}, | ||
); | ||
|
||
const module = argv.module || null; | ||
|
||
if (module === null) { | ||
console.error( | ||
`[ERROR] --module is required`, | ||
); | ||
Deno.exit(1); | ||
} | ||
|
||
const di = await load<denoImports>(join(module, "deno.json")); | ||
const nd = await load<nodeDependencies>(join(module, "package.json")); | ||
|
||
// drive the dependencies from the deno.json, as npm may contain additional ones | ||
let failed = false; | ||
let fixed = false; | ||
|
||
for (const lib in di.imports) { | ||
let deno = di.imports[lib]; | ||
const prefix = `jsr:${lib}@`; | ||
if (deno.startsWith(prefix)) { | ||
deno = deno.substring(prefix.length); | ||
} | ||
|
||
if (argv.f) { | ||
if (nd.dependencies[lib] !== deno) { | ||
console.log( | ||
`changed in package.json ${lib} from ${ | ||
nd.dependencies[lib] | ||
} to ${deno}`, | ||
); | ||
nd.dependencies[lib] = deno; | ||
fixed = true; | ||
} | ||
continue; | ||
} | ||
|
||
if (argv.v === true) { | ||
const node = nd.dependencies[lib]; | ||
console.log({ lib, deno, node }); | ||
} | ||
if (!nd.dependencies[lib]) { | ||
failed = true; | ||
console.log( | ||
`[ERROR] module ${module} package.json dependencies is missing: ${lib}`, | ||
); | ||
continue; | ||
} | ||
if (deno !== nd.dependencies[lib]) { | ||
failed = true; | ||
console.log( | ||
`[ERROR] module ${module} package.json dependencies ${lib}: ${ | ||
nd.dependencies[lib] | ||
} - but should be ${deno}`, | ||
); | ||
} | ||
} | ||
|
||
if (argv.f && fixed) { | ||
await Deno.writeTextFile( | ||
join(module, "package.json"), | ||
JSON.stringify(nd, undefined, " "), | ||
); | ||
console.log(`[OK] module ${module} updated package.json`); | ||
Deno.exit(0); | ||
} | ||
|
||
if (failed) { | ||
Deno.exit(1); | ||
} | ||
console.log(`[OK] module ${module}`); | ||
Deno.exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
}, | ||
"tasks": { | ||
"clean": "rm -rf ./lib ./cjs ./esm", | ||
"test": "deno test -A --parallel --reload --quiet tests/ --import-map=./import_map.json" | ||
"test": "deno test -A --parallel --reload --quiet tests/ --import-map=./import_map.json", | ||
}, | ||
"imports": { | ||
"@nats-io/nkeys": "jsr:@nats-io/[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"imports": { | ||
"@nats-io/nkeys": "jsr:@nats-io/[email protected]", | ||
"@nats-io/nuid": "jsr:@nats-io/[email protected]", | ||
"@nats-io/nats-core": "jsr:@nats-io/[email protected]", | ||
"@nats-io/jetstream/internal": "./src/internal_mod.ts", | ||
"test_helpers": "../test_helpers/mod.ts", | ||
"@std/io": "jsr:@std/[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "@nats-io/kv", | ||
"version": "3.0.0-2", | ||
"files": [ | ||
"lib/" | ||
], | ||
"types": "./lib/mod.d.js", | ||
"exports": { | ||
".": "./lib/mod.js", | ||
"./internal": "./lib/internal_mod.js" | ||
}, | ||
"license": "Apache-2.0", | ||
"private": false, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"clean": "shx rm -Rf ./lib ./cjs ./esm && shx mkdir esm", | ||
"pre-process": "npm run clean && deno run -A ../bin/cjs-fix-imports.ts -o ./cjs ./src", | ||
"build-cjs": "npm run pre-process && tsc", | ||
"build": "npm run build-cjs", | ||
"prepack": "npm run build" | ||
}, | ||
"keywords": [], | ||
"author": { | ||
"name": "The NATS Authors" | ||
}, | ||
"description": "nats-core library - this library implements all the base functionality for NATS javascript clients", | ||
"dependencies": { | ||
"@nats-io/nats-core": "3.0.0-17", | ||
"shx": "^0.3.4", | ||
"typescript": "^5.4.5", | ||
"@nats-io/jetstream": "3.0.0-3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version": "3.0.0-5" | ||
} |