Embed version in the JavaScript client (#2229)
This commit is contained in:
parent
e1f7cb4105
commit
76a6cbcd84
|
|
@ -0,0 +1,44 @@
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const pkg = require(path.resolve(process.cwd(), "package.json"));
|
||||||
|
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
let verbose = false;
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
switch (args[i]) {
|
||||||
|
case "-v":
|
||||||
|
verbose = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function processDirectory(dir) {
|
||||||
|
if (verbose) {
|
||||||
|
console.log(`processing ${dir}`);
|
||||||
|
}
|
||||||
|
for (const item of fs.readdirSync(dir)) {
|
||||||
|
const fullPath = path.resolve(dir, item);
|
||||||
|
const stats = fs.statSync(fullPath);
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
processDirectory(fullPath);
|
||||||
|
} else if (stats.isFile()) {
|
||||||
|
processFile(fullPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const SEARCH_STRING = "0.0.0-DEV_BUILD";
|
||||||
|
function processFile(file) {
|
||||||
|
if (file.endsWith(".js") || file.endsWith(".ts")) {
|
||||||
|
if (verbose) {
|
||||||
|
console.log(`processing ${file}`);
|
||||||
|
}
|
||||||
|
let content = fs.readFileSync(file);
|
||||||
|
content = content.toString().replace(SEARCH_STRING, pkg.version);
|
||||||
|
fs.writeFileSync(file, content);
|
||||||
|
} else if (verbose) {
|
||||||
|
console.log(`skipping ${file}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processDirectory(path.resolve(process.cwd(), "dist"));
|
||||||
|
|
@ -19,7 +19,10 @@ export default function(rootDir, moduleGlobals) {
|
||||||
format: "umd",
|
format: "umd",
|
||||||
name: pkg.umd_name,
|
name: pkg.umd_name,
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
banner: "/* @license\r\n" +
|
banner: "/** \r\n" +
|
||||||
|
" * @overview ASP.NET Core SignalR JavaScript Client.\r\n" +
|
||||||
|
" * @version 0.0.0-DEV_BUILD.\r\n" +
|
||||||
|
" * @license\r\n" +
|
||||||
" * Copyright (c) .NET Foundation. All rights reserved.\r\n" +
|
" * Copyright (c) .NET Foundation. All rights reserved.\r\n" +
|
||||||
" * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\r\n" +
|
" * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\r\n" +
|
||||||
" */",
|
" */",
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
"build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs",
|
"build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs",
|
||||||
"build:browser": "node ../node_modules/rollup/bin/rollup -c",
|
"build:browser": "node ../node_modules/rollup/bin/rollup -c",
|
||||||
"build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr-protocol-msgpack.min.js.map',content='./dist/browser/signalr-protocol-msgpack.js.map'\" --comments -o ./dist/browser/signalr-protocol-msgpack.min.js ./dist/browser/signalr-protocol-msgpack.js",
|
"build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr-protocol-msgpack.min.js.map',content='./dist/browser/signalr-protocol-msgpack.js.map'\" --comments -o ./dist/browser/signalr-protocol-msgpack.min.js ./dist/browser/signalr-protocol-msgpack.js",
|
||||||
|
"prepack": "node ../build/embed-version.js",
|
||||||
"test": "echo \"Run 'npm test' in the 'clients\\ts' folder to test this package\" && exit 1"
|
"test": "echo \"Run 'npm test' in the 'clients\\ts' folder to test this package\" && exit 1"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
// Version token that will be replaced by the prepack command
|
||||||
|
/** The version of the SignalR Message Pack protocol library. */
|
||||||
|
export const VERSION = "0.0.0-DEV_BUILD";
|
||||||
|
|
||||||
export { MessagePackHubProtocol } from "./MessagePackHubProtocol";
|
export { MessagePackHubProtocol } from "./MessagePackHubProtocol";
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
"build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs",
|
"build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs",
|
||||||
"build:browser": "node ../node_modules/rollup/bin/rollup -c",
|
"build:browser": "node ../node_modules/rollup/bin/rollup -c",
|
||||||
"build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr.min.js.map',content='./dist/browser/signalr.js.map'\" --comments -o ./dist/browser/signalr.min.js ./dist/browser/signalr.js",
|
"build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr.min.js.map',content='./dist/browser/signalr.js.map'\" --comments -o ./dist/browser/signalr.min.js ./dist/browser/signalr.js",
|
||||||
|
"prepack": "node ../build/embed-version.js",
|
||||||
"test": "echo \"Run 'npm test' in the 'clients\\ts' folder to test this package\" && exit 1"
|
"test": "echo \"Run 'npm test' in the 'clients\\ts' folder to test this package\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
// Version token that will be replaced by the prepack command
|
||||||
|
/** The version of the SignalR client. */
|
||||||
|
export const VERSION: string = "0.0.0-DEV_BUILD";
|
||||||
|
|
||||||
// Everything that users need to access must be exported here. Including interfaces.
|
// Everything that users need to access must be exported here. Including interfaces.
|
||||||
export { AbortSignal } from "./AbortController";
|
export { AbortSignal } from "./AbortController";
|
||||||
export { HttpError, TimeoutError } from "./Errors";
|
export { HttpError, TimeoutError } from "./Errors";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue