ngx-deploy-npm
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -10,4 +10,14 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function deploy(engine, context, projectRoot, options) { | ||
const architect_1 = require("@angular-devkit/architect"); | ||
const path = __importStar(require("path")); | ||
const utils_1 = require("../utils"); | ||
function deploy(engine, context, buildTarget, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -33,6 +43,32 @@ if (options.noBuild) { | ||
} | ||
yield engine.run(projectRoot, options, context.logger); | ||
const targetFromStr = architect_1.targetFromTargetString(buildTarget.name); | ||
const buildOptions = yield context.getTargetOptions(targetFromStr); | ||
if (!buildOptions.project || typeof buildOptions.project !== 'string') { | ||
throw new Error(`Cannot read the project path option of the Angular library '${buildTarget.name}' in angular.json`); | ||
} | ||
const outputPath = yield getOutPutPath(context.workspaceRoot, buildOptions.project); | ||
yield engine.run(outputPath, options, context.logger); | ||
}); | ||
} | ||
exports.default = deploy; | ||
function getOutPutPath(projectRoot, relativeNgPackagePath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const ngPackagePath = path.join(projectRoot, relativeNgPackagePath); | ||
let ngPackageContentStr; | ||
try { | ||
ngPackageContentStr = yield utils_1.readFileAsync(ngPackagePath, { | ||
encoding: 'utf8' | ||
}); | ||
} | ||
catch (error) { | ||
throw new Error(`Error reading the ng-package.json`); | ||
} | ||
const ngPackageContent = JSON.parse(ngPackageContentStr); | ||
if (!ngPackageContent.dest || typeof ngPackageContent.dest !== 'string') { | ||
throw new Error(`Cannot read the project 'dest' option of the ng-package.json`); | ||
} | ||
const outputPath = path.join(path.dirname(ngPackagePath), ngPackageContent.dest); | ||
return outputPath; | ||
}); | ||
} | ||
//# sourceMappingURL=actions.js.map |
@@ -10,5 +10,2 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
@@ -21,27 +18,21 @@ if (mod && mod.__esModule) return mod; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const architect_1 = require("@angular-devkit/architect"); | ||
const core_1 = require("@angular-devkit/core"); | ||
const node_1 = require("@angular-devkit/core/node"); | ||
const os_1 = __importDefault(require("os")); | ||
const path = __importStar(require("path")); | ||
const engine = __importStar(require("../engine/engine")); | ||
const actions_1 = __importDefault(require("./actions")); | ||
exports.default = architect_1.createBuilder((options, context) => __awaiter(this, void 0, void 0, function* () { | ||
const root = core_1.normalize(context.workspaceRoot); | ||
const workspace = new core_1.experimental.workspace.Workspace(root, new node_1.NodeJsSyncHost()); | ||
yield workspace | ||
.loadWorkspaceFromHost(core_1.normalize('angular.json')) | ||
.toPromise(); | ||
if (!context.target) { | ||
throw new Error('Cannot deploy the application without a target'); | ||
} | ||
const targets = workspace.getProjectTargets(context.target.project); | ||
const outputPath = yield getLibraryOutputPath(targets); | ||
const isWin = os_1.default.platform() === 'win32'; | ||
const workspaceRoot = !isWin | ||
? workspace.root | ||
: core_1.asWindowsPath(workspace.root); | ||
const configuration = options.configuration | ||
? `:${options.configuration}` | ||
: ''; | ||
const buildTarget = { | ||
name: `${context.target.project}:build${configuration}` | ||
}; | ||
try { | ||
yield actions_1.default(engine, context, path.join(workspaceRoot, outputPath), options); | ||
yield actions_1.default(engine, context, buildTarget, options); | ||
} | ||
@@ -55,26 +46,2 @@ catch (e) { | ||
})); | ||
const fs = require('fs'); | ||
function readFileAsync(path) { | ||
return new Promise((res, rej) => { | ||
fs.readFile(path, 'utf8', function (err, contents) { | ||
if (err) | ||
rej(err); | ||
res(contents); | ||
}); | ||
}); | ||
} | ||
function getLibraryOutputPath(targets) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const ngPackagePath = targets.build.options.project; | ||
try { | ||
const dataStr = yield readFileAsync(ngPackagePath); | ||
const data = JSON.parse(dataStr); | ||
const fullPath = data.dest.replace(/\.\.\//g, ''); | ||
return fullPath; | ||
} | ||
catch (err) { | ||
throw new Error('An error occurs reading the ng-package.json'); | ||
} | ||
}); | ||
} | ||
//# sourceMappingURL=builder.js.map |
@@ -19,4 +19,4 @@ "use strict"; | ||
const path = __importStar(require("path")); | ||
const fs = __importStar(require("./utils/fs-async")); | ||
const exec_async_1 = require("./utils/exec-async"); | ||
const fs = __importStar(require("../utils/fs-async")); | ||
const exec_async_1 = require("../utils/exec-async"); | ||
const defaults_1 = require("./defaults"); | ||
@@ -28,3 +28,3 @@ function run(dir, options, logger) { | ||
if (options.packageVersion && !options.dryRun) { | ||
yield setPackageVersion(dir, options); | ||
yield setPackageVersion(dir, options.packageVersion); | ||
} | ||
@@ -49,7 +49,7 @@ const npmOptions = extractOnlyNPMOptions(options); | ||
exports.run = run; | ||
function setPackageVersion(dir, options) { | ||
function setPackageVersion(dir, packageVersion) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let packageContent = yield fs.readFileAsync(path.join(dir, 'package.json'), { encoding: 'utf8' }); | ||
let packageObj = JSON.parse(packageContent); | ||
packageObj.version = options.packageVersion; | ||
const packageContent = yield fs.readFileAsync(path.join(dir, 'package.json'), { encoding: 'utf8' }); | ||
const packageObj = JSON.parse(packageContent); | ||
packageObj.version = packageVersion; | ||
yield fs.writeFileAsync(path.join(dir, 'package.json'), JSON.stringify(packageObj, null, 4), { encoding: 'utf8' }); | ||
@@ -56,0 +56,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core_1 = require("@angular-devkit/core"); | ||
const schematics_1 = require("@angular-devkit/schematics"); | ||
const core_1 = require("@angular-devkit/core"); | ||
const defaults_1 = require("./engine/defaults"); | ||
@@ -6,0 +6,0 @@ function getWorkspace(host) { |
{ | ||
"name": "ngx-deploy-npm", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Publish your angular packages to npm by just run `npm deploy your-packages`", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "rimraf dist && json2ts deploy/schema.json > deploy/schema.d.ts && tsc && copyfiles README.md LICENSE builders.json collection.json package.json ngx-deploy-npm deploy/schema.json dist", | ||
"prebuild": "rimraf dist && copyfiles README.md LICENSE builders.json collection.json package.json ngx-deploy-npm deploy/schema.json dist && json2ts deploy/schema.json > deploy/schema.d.ts", | ||
"build": "tsc -p tsconfig.build.json", | ||
"predeploy": "npm run build", | ||
@@ -47,5 +48,5 @@ "deploy": "cd dist && npm publish --access public && cd ..", | ||
"devDependencies": { | ||
"@angular-devkit/architect": "^0.803.0", | ||
"@angular-devkit/core": "^8.3.0", | ||
"@angular-devkit/schematics": "^8.3.0", | ||
"@angular-devkit/architect": "^0.1100.0", | ||
"@angular-devkit/core": "^11.0.0", | ||
"@angular-devkit/schematics": "^11.0.0", | ||
"@types/jest": "^24.0.18", | ||
@@ -52,0 +53,0 @@ "@types/node": "^12.6.9", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
47747
30
369
2