Skip to content
代码片段 群组 项目
提交 f005e80b 编辑于 作者: Andrew Stanton-Nurse's avatar Andrew Stanton-Nurse
浏览文件

Embed version in the JavaScript client (#2229)

上级 4b1fb58a
No related branches found
No related tags found
无相关合并请求
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"));
\ No newline at end of file
......@@ -19,7 +19,10 @@ export default function(rootDir, moduleGlobals) {
format: "umd",
name: pkg.umd_name,
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" +
" * 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: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",
"prepack": "node ../build/embed-version.js",
"test": "echo \"Run 'npm test' in the 'clients\\ts' folder to test this package\" && exit 1"
},
"keywords": [
......
// 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.
// 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";
......@@ -18,6 +18,7 @@
"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: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"
},
"repository": {
......
// 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.
// 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.
export { AbortSignal } from "./AbortController";
export { HttpError, TimeoutError } from "./Errors";
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册