[Main] Fix npm pack and publish issues (#73)
This commit is contained in:
Родитель
7ae4cad59c
Коммит
fc6aae6d77
|
@ -27,11 +27,13 @@ node_modules/
|
|||
out/
|
||||
dist**/
|
||||
types/
|
||||
tools/
|
||||
|
||||
lib/bundle/
|
||||
lib/dist**/
|
||||
lib/types/
|
||||
lib/tools/
|
||||
lib/README*
|
||||
lib/LICENSE
|
||||
|
||||
rollup/node_modules/
|
||||
rollup/dist**/
|
||||
|
|
|
@ -391,9 +391,9 @@
|
|||
"integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA=="
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.15.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.10.tgz",
|
||||
"integrity": "sha512-9avDaQJczATcXgfmMAW3MIWArOO7A+m90vuCFLr8AotWf8igO/mRoYukrk2cqZVtv38tHs33retzHEilM7FpeQ=="
|
||||
"version": "18.15.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
|
||||
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q=="
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "1.17.1",
|
||||
|
@ -4611,9 +4611,9 @@
|
|||
"integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "18.15.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.10.tgz",
|
||||
"integrity": "sha512-9avDaQJczATcXgfmMAW3MIWArOO7A+m90vuCFLr8AotWf8igO/mRoYukrk2cqZVtv38tHs33retzHEilM7FpeQ=="
|
||||
"version": "18.15.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
|
||||
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q=="
|
||||
},
|
||||
"@types/resolve": {
|
||||
"version": "1.17.1",
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# NPM Ignore
|
||||
|
||||
# ignore everything
|
||||
*
|
||||
|
||||
# ... but these files
|
||||
!package.json
|
||||
!CODE_OF_CONDUCT.md
|
||||
!CONTRIBUTING.md
|
||||
!README.md
|
||||
!SECURITY
|
||||
!SECURITY.md
|
||||
!SUPPORT.md
|
||||
!NOTICE
|
||||
!PRIVACY
|
||||
!RELEASES.md
|
||||
!LICENSE
|
||||
!LICENSE.TXT
|
||||
!dist/**/*
|
||||
!dist-es5/**/*
|
||||
!types/**/*
|
||||
!tools/rollup/dist-es5/**/*
|
||||
!tools/rollup/types/**/*
|
||||
!tools/rollup/package.json
|
|
@ -3,7 +3,7 @@ import copy from "rollup-plugin-copy";
|
|||
import replace from "@rollup/plugin-replace";
|
||||
import minify from 'rollup-plugin-minify-es';
|
||||
import cleanup from "rollup-plugin-cleanup";
|
||||
import dynamicRemove from "../rollup/dist-es5/removeDynamic";
|
||||
import dynamicRemove from "./tools/rollup/dist-es5/removeDynamic";
|
||||
import { es3Check, es3Poly } from "@microsoft/applicationinsights-rollup-es3";
|
||||
|
||||
const UglifyJs = require('uglify-js');
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
require([
|
||||
"qunit", // Load qunit here instead of with tests, otherwise will not work
|
||||
"@nevware21/ts-utils"
|
||||
], function (QUnit, tsUtils, aicore) {
|
||||
], function (QUnit, tsUtils) {
|
||||
require.config({
|
||||
baseUrl: './'
|
||||
});
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
"rupdate": "node common/scripts/install-run-rush.js update --recheck --purge --full",
|
||||
"docs": "typedoc",
|
||||
"fullClean": "git clean -xdf && npm install && rush update --recheck --purge --full",
|
||||
"fullCleanBuild": "npm run fullClean && npm run build"
|
||||
"fullCleanBuild": "npm run fullClean && npm run build",
|
||||
"npm_pack": "copyfiles README.md LICENSE lib && cd lib && npm pack",
|
||||
"npm_publish": "cd lib && node ../tools/release-tools/npm_publish.js ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -63,6 +65,7 @@
|
|||
"rollup-plugin-cleanup": "3.2.1",
|
||||
"rollup": "^2.32.0",
|
||||
"typedoc": "^0.23.25",
|
||||
"typescript": "^4.9.5"
|
||||
"typescript": "^4.9.5",
|
||||
"copyfiles": "^2.4.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import replace from "@rollup/plugin-replace";
|
|||
import cleanup from "rollup-plugin-cleanup";
|
||||
|
||||
const version = require("./package.json").version;
|
||||
const inputName = "./dist-es5/removeDynamic";
|
||||
const inputName = "../lib/tools/rollup/dist-es5/removeDynamic";
|
||||
const outputName = "removedynamic";
|
||||
const distPath = "../tools/rollup/";
|
||||
const distPath = "../lib/tools/rollup/";
|
||||
const banner = [
|
||||
"/*!",
|
||||
` * Microsoft Dynamic Proto Rollup Utility, ${version}`,
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
"noEmitHelpers": false,
|
||||
"alwaysStrict": true,
|
||||
"declaration": true,
|
||||
"declarationDir": "./types",
|
||||
"declarationDir": "../lib/tools/rollup/types",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist-es5",
|
||||
"outDir": "../lib/tools/rollup/dist-es5",
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"removeComments": false
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
const fs = require("fs");
|
||||
const child_process = require("child_process");
|
||||
|
||||
let packageRoot;
|
||||
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 + " <pkgFolder> ");
|
||||
console.log("--------------------------");
|
||||
console.log(" <pkgFolder> - Identifies the folder containing the package.json and *.tgz");
|
||||
}
|
||||
|
||||
function parseArgs() {
|
||||
if (process.argv.length < 2) {
|
||||
console.error("!!! Invalid number of arguments -- " + process.argv.length);
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log("cwd: " + process.cwd());
|
||||
|
||||
let idx = 2;
|
||||
while (idx < process.argv.length) {
|
||||
let theArg = process.argv[idx];
|
||||
if (!packageRoot) {
|
||||
packageRoot = theArg;
|
||||
} else if(theArg === "-test") {
|
||||
dryRun = "--dry-run";
|
||||
} else {
|
||||
console.error("!!! Invalid Argument [" + theArg + "] detected");
|
||||
return false;
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function removeTrailingComma(text) {
|
||||
return text.replace(/,(\s*[}\],])/g, "$1");
|
||||
}
|
||||
|
||||
function getNpmPackageName(packageJsonFile) {
|
||||
var packageText = removeTrailingComma(fs.readFileSync(packageJsonFile, "utf-8"));
|
||||
|
||||
let packageJson = JSON.parse(packageText);
|
||||
let packageName = packageJson.name;
|
||||
let packageVersion = packageJson.version;
|
||||
|
||||
let theNpmPackageName = packageName + "-" + packageVersion;
|
||||
|
||||
theNpmPackageName = theNpmPackageName.replace("@", "").replace("/", "-");
|
||||
|
||||
return theNpmPackageName + ".tgz";
|
||||
|
||||
}
|
||||
|
||||
if (parseArgs()) {
|
||||
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 + "]");
|
||||
}
|
||||
|
||||
let npmPackageName = packageRoot + "/" + getNpmPackageName(packageJsonFile);
|
||||
if (!fs.existsSync(npmPackageName)) {
|
||||
console.error("!!! NPM Package not found [" + npmPackageName + "]");
|
||||
throw new Error("!!! NPM Package not found [" + npmPackageName + "]");
|
||||
}
|
||||
|
||||
console.log(`npm pacakage present ${npmPackageName}`);
|
||||
let npmCmd = `npm publish ${npmPackageName} --access public ${dryRun}`;
|
||||
console.log(`Running: \"${npmCmd}\"`);
|
||||
child_process.execSync(npmCmd);
|
||||
} else {
|
||||
showHelp();
|
||||
process.exit(1);
|
||||
}
|
Загрузка…
Ссылка в новой задаче