Internal Task: Update npm pack sequence (#2244)
This commit is contained in:
Родитель
75c9971140
Коммит
846cc6d1df
|
@ -180,6 +180,7 @@ browser/
|
|||
types/
|
||||
dist/
|
||||
dest/
|
||||
drop/
|
||||
|
||||
# Don't commit the sub resource integrity generated files
|
||||
**/*.integrity.json
|
||||
|
|
|
@ -2150,9 +2150,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001578",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001578.tgz",
|
||||
"integrity": "sha512-J/jkFgsQ3NEl4w2lCoM9ZPxrD+FoBNJ7uJUpGVjIg/j0OwJosWM36EPDv+Yyi0V4twBk9pPmlFS+PLykgEvUmg==",
|
||||
"version": "1.0.30001579",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz",
|
||||
"integrity": "sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
|
@ -2535,9 +2535,9 @@
|
|||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.4.636",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.636.tgz",
|
||||
"integrity": "sha512-NLE0GIy1OL9wRiKL20h9TkctBEYZuc99tquSS9MVdTahnuHputoETHeqDzgqGqyOY9NUH0g9wjfEuw5OD+wRcQ=="
|
||||
"version": "1.4.637",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.637.tgz",
|
||||
"integrity": "sha512-G7j3UCOukFtxVO1vWrPQUoDk3kL70mtvjc/DC/k2o7lE0wAdq+Vwp1ipagOow+BH0uVztFysLWbkM/RTIrbK3w=="
|
||||
},
|
||||
"node_modules/encodeurl": {
|
||||
"version": "1.0.2",
|
||||
|
@ -7970,9 +7970,9 @@
|
|||
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001578",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001578.tgz",
|
||||
"integrity": "sha512-J/jkFgsQ3NEl4w2lCoM9ZPxrD+FoBNJ7uJUpGVjIg/j0OwJosWM36EPDv+Yyi0V4twBk9pPmlFS+PLykgEvUmg=="
|
||||
"version": "1.0.30001579",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz",
|
||||
"integrity": "sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA=="
|
||||
},
|
||||
"chalk": {
|
||||
"version": "4.1.2",
|
||||
|
@ -8252,9 +8252,9 @@
|
|||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.4.636",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.636.tgz",
|
||||
"integrity": "sha512-NLE0GIy1OL9wRiKL20h9TkctBEYZuc99tquSS9MVdTahnuHputoETHeqDzgqGqyOY9NUH0g9wjfEuw5OD+wRcQ=="
|
||||
"version": "1.4.637",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.637.tgz",
|
||||
"integrity": "sha512-G7j3UCOukFtxVO1vWrPQUoDk3kL70mtvjc/DC/k2o7lE0wAdq+Vwp1ipagOow+BH0uVztFysLWbkM/RTIrbK3w=="
|
||||
},
|
||||
"encodeurl": {
|
||||
"version": "1.0.2",
|
||||
|
|
|
@ -54,5 +54,8 @@
|
|||
"@microsoft/applicationinsights-web": "3.0.7",
|
||||
"@microsoft/applicationinsights-core-js": "3.0.7",
|
||||
"@nevware21/ts-utils": ">= 0.10.4 < 2.x"
|
||||
},
|
||||
"publishConfig": {
|
||||
"tag": "example"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,5 +67,8 @@
|
|||
"@microsoft/applicationinsights-web": "3.0.7",
|
||||
"@microsoft/applicationinsights-core-js": "3.0.7",
|
||||
"@nevware21/ts-utils": ">= 0.10.4 < 2.x"
|
||||
},
|
||||
"publishConfig": {
|
||||
"tag": "example"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,5 +55,8 @@
|
|||
"@microsoft/applicationinsights-dependencies-js": "3.0.7",
|
||||
"@microsoft/applicationinsights-core-js": "3.0.7",
|
||||
"@nevware21/ts-utils": ">= 0.10.4 < 2.x"
|
||||
},
|
||||
"publishConfig": {
|
||||
"tag": "example"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,5 +67,8 @@
|
|||
"@microsoft/applicationinsights-web-snippet": "1.1.5",
|
||||
"@microsoft/applicationinsights-core-js": "3.0.7",
|
||||
"@nevware21/ts-utils": ">= 0.10.4 < 2.x"
|
||||
},
|
||||
"publishConfig": {
|
||||
"tag": "example"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
"ai-min": "node common/scripts/install-run-rush.js ai-min",
|
||||
"ai-restore": "node common/scripts/install-run-rush.js ai-restore",
|
||||
"npm-pack": "node common/scripts/install-run-rush.js npm-pack --verbose",
|
||||
"npm-package": "node ./tools/release-tools/npm_package.js",
|
||||
"npm-publish": "node ./tools/release-tools/npm_publish.js",
|
||||
"npm-set-latest": "node ./tools/release-tools/npm_set_latest.js",
|
||||
"gh-status": "node ./tools/status-tools/github-status.js",
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
const fs = require("fs");
|
||||
const child_process = require("child_process");
|
||||
|
||||
const packageGroupDef = "./tools/release-tools/package_groups.json";
|
||||
let packageGroup;
|
||||
let dropFolder;
|
||||
let dryRun = "";
|
||||
|
||||
function showHelp() {
|
||||
var scriptParts;
|
||||
var scriptName = process.argv[1];
|
||||
if (scriptName.indexOf("\\") !== -1) {
|
||||
scriptParts = scriptName.split("\\");
|
||||
scriptName = scriptParts[scriptParts.length - 1];
|
||||
} else if (scriptName.indexOf("/") !== -1) {
|
||||
scriptParts = scriptName.split("/");
|
||||
scriptName = scriptParts[scriptParts.length - 1];
|
||||
}
|
||||
|
||||
console.log("");
|
||||
console.log(scriptName + " <group> ");
|
||||
console.log("--------------------------");
|
||||
console.log(" <group> - Identifies the group to publish, identifies folders, the group must be defined in package_groups.json");
|
||||
console.log(" <dropFolder> - Identifies the base folder to drop the packages into, defaults to ./drop/packages/<group>");
|
||||
}
|
||||
|
||||
function parseArgs() {
|
||||
console.log("Parsing args - " + process.argv.join(" "));
|
||||
if (process.argv.length < 2) {
|
||||
console.error("!!! Invalid number of arguments -- " + process.argv.length);
|
||||
return false;
|
||||
}
|
||||
|
||||
let idx = 2;
|
||||
while (idx < process.argv.length) {
|
||||
let theArg = process.argv[idx];
|
||||
if (theArg.startsWith("-")) {
|
||||
if (theArg === "-test") {
|
||||
dryRun = "--dry-run";
|
||||
} else {
|
||||
console.error("!!! Unknown switch [" + theArg + "] detected");
|
||||
return false;
|
||||
}
|
||||
} else if (!packageGroup) {
|
||||
packageGroup = theArg;
|
||||
} else if (!dropFolder) {
|
||||
dropFolder = theArg;
|
||||
} else {
|
||||
console.error("!!! Invalid Argument [" + theArg + "] detected");
|
||||
return false;
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
// Check for required arguments
|
||||
if (!packageGroup) {
|
||||
console.error("!!! Missing package group");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function removeTrailingComma(text) {
|
||||
return text.replace(/,(\s*[}\],])/g, "$1");
|
||||
}
|
||||
|
||||
function removeComments(text) {
|
||||
return text.replace(/^\s*\/\/\s.*$/gm, "");
|
||||
}
|
||||
|
||||
function getPackage(packageJsonFile) {
|
||||
var packageText = removeTrailingComma(fs.readFileSync(packageJsonFile, "utf-8"));
|
||||
|
||||
return JSON.parse(packageText);
|
||||
}
|
||||
|
||||
function getNpmPackageName(packageJson) {
|
||||
let packageName = packageJson.name;
|
||||
let packageVersion = packageJson.version;
|
||||
|
||||
let theNpmPackageName = packageName + "-" + packageVersion;
|
||||
|
||||
theNpmPackageName = theNpmPackageName.replace("@", "").replace("/", "-");
|
||||
|
||||
return theNpmPackageName + ".tgz";
|
||||
}
|
||||
|
||||
function getGroupProjects() {
|
||||
if (!fs.existsSync(packageGroupDef)) {
|
||||
console.error("!!! Unable to locate package group definitions [" + packageGroupDef + "]");
|
||||
throw new Error("!!! Unable to locate package group definitions.");
|
||||
}
|
||||
|
||||
var groupText = removeComments(removeTrailingComma(fs.readFileSync(packageGroupDef, "utf-8")));
|
||||
|
||||
let groupJson = JSON.parse(groupText);
|
||||
return groupJson[packageGroup] || [];
|
||||
}
|
||||
|
||||
function movePackage(npmPackageName, packageName) {
|
||||
let packageFolder = dropFolder;
|
||||
if (!packageFolder) {
|
||||
packageFolder = "./drop/packages";
|
||||
packageFolder += "/" + packageGroup;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(packageFolder)) {
|
||||
fs.mkdirSync(packageFolder, { recursive: true });
|
||||
}
|
||||
|
||||
let packageFile = packageFolder + "/" + packageName;
|
||||
if (fs.existsSync(packageFile)) {
|
||||
console.log(` -- Removing existing package ${packageFile}`);
|
||||
fs.unlinkSync(packageFile);
|
||||
}
|
||||
|
||||
console.log(` -- Moving ${npmPackageName} to ${packageFile}`);
|
||||
fs.renameSync(npmPackageName, packageFile);
|
||||
}
|
||||
|
||||
if (parseArgs()) {
|
||||
var packages = getGroupProjects();
|
||||
|
||||
console.log(`Creating [${packageGroup}] packages => ${packages.length}`);
|
||||
packages.forEach((packageRoot) => {
|
||||
let packageJsonFile = packageRoot + "/package.json";
|
||||
|
||||
if (!fs.existsSync(packageJsonFile)) {
|
||||
console.error("!!! Source package.json doesn't exist [" + packageJsonFile + "]");
|
||||
throw new Error("!!! Source package.json doesn't exist [" + packageJsonFile + "]");
|
||||
}
|
||||
|
||||
const packageJson = getPackage(packageJsonFile);
|
||||
|
||||
const packageName = getNpmPackageName(packageJson);
|
||||
console.log("\n\n##################################################################");
|
||||
console.log("Packaging - " + packageName);
|
||||
console.log("##################################################################");
|
||||
|
||||
let npmPackageName = packageRoot + "/" + packageName;
|
||||
if (fs.existsSync(npmPackageName)) {
|
||||
console.log(` -- Removing existing package ${npmPackageName}`);
|
||||
fs.unlinkSync(npmPackageName);
|
||||
}
|
||||
|
||||
const cwd = process.cwd();
|
||||
process.chdir(packageRoot);
|
||||
try {
|
||||
let npmCmd = `npm pack ${dryRun}`;
|
||||
console.log(`Running: \"${npmCmd}\"`);
|
||||
child_process.execSync(npmCmd);
|
||||
} finally {
|
||||
process.chdir(cwd);
|
||||
}
|
||||
|
||||
if (!dryRun) {
|
||||
// Move the package to the package folder
|
||||
movePackage(npmPackageName, packageName);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showHelp();
|
||||
process.exit(1);
|
||||
}
|
|
@ -48,6 +48,12 @@ function parseArgs() {
|
|||
idx++;
|
||||
}
|
||||
|
||||
// Check for required arguments
|
||||
if (!packageGroup) {
|
||||
console.error("!!! Missing package group");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,5 +53,11 @@
|
|||
// Snippet packages
|
||||
"snippet": [
|
||||
"./tools/applicationinsights-web-snippet"
|
||||
],
|
||||
"examples": [
|
||||
"./examples/AISKU",
|
||||
"./examples/cfgSync",
|
||||
"./examples/dependency",
|
||||
"./examples/shared-worker"
|
||||
]
|
||||
}
|
Загрузка…
Ссылка в новой задаче