@nxlv/python
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -10,2 +10,8 @@ # Changelog | ||
## [1.7.0] - 2022-07-13 | ||
### Changed | ||
- Modify `@nxlv/nx-python:add` executor to add the CLI option `--group`. | ||
## [1.6.0] - 2022-07-12 | ||
@@ -12,0 +18,0 @@ |
{ | ||
"name": "@nxlv/python", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Custom NX Plugin to support the Python language", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -7,4 +7,5 @@ "use strict"; | ||
const update_dependency_1 = require("../../dependency/update-dependency"); | ||
const executor_1 = require("../update/executor"); | ||
const fs_extra_1 = require("fs-extra"); | ||
const path_1 = (0, tslib_1.__importDefault)(require("path")); | ||
const poetry_1 = require("../utils/poetry"); | ||
function executor(options, context) { | ||
@@ -19,11 +20,12 @@ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
console.log((0, chalk_1.default) `\n {bold Adding {bgBlue ${options.name} } workspace dependency...}\n`); | ||
(0, executor_1.updateLocalProject)(context, options.name, projectConfig, rootPyprojectToml); | ||
updateLocalProject(context, options.name, projectConfig, rootPyprojectToml, options.group); | ||
} | ||
else { | ||
console.log((0, chalk_1.default) `\n {bold Adding {bgBlue ${options.name} } dependency...}\n`); | ||
const executable = "poetry"; | ||
const executable = 'poetry'; | ||
const installArgs = ['add', options.name] | ||
.concat(options.group ? ['--group', options.group] : []) | ||
.concat(options.args ? options.args.split(' ') : []) | ||
.concat(rootPyprojectToml ? ['--lock'] : []); | ||
const installCommand = `${executable} ${installArgs.join(" ")}`; | ||
const installCommand = `${executable} ${installArgs.join(' ')}`; | ||
console.log((0, chalk_1.default) `{bold Running command}: ${installCommand} at {bold ${projectConfig.root}} folder\n`); | ||
@@ -33,3 +35,3 @@ (0, child_process_1.spawnSync)(executable, installArgs, { | ||
shell: false, | ||
stdio: 'inherit' | ||
stdio: 'inherit', | ||
}); | ||
@@ -52,2 +54,8 @@ } | ||
exports.default = executor; | ||
function updateLocalProject(context, dependencyName, projectConfig, updateLockOnly, group) { | ||
const dependencyConfig = (0, poetry_1.getLocalDependencyConfig)(context, dependencyName); | ||
const dependencyPath = path_1.default.relative(projectConfig.root, dependencyConfig.root); | ||
const dependencyPkgName = (0, poetry_1.addLocalProjectToPoetryProject)(projectConfig, dependencyConfig, dependencyPath, group); | ||
(0, poetry_1.updateProject)(dependencyPkgName, projectConfig.root, updateLockOnly); | ||
} | ||
//# sourceMappingURL=executor.js.map |
@@ -5,2 +5,3 @@ export interface AddExecutorSchema { | ||
args?: string; | ||
group?: string; | ||
} |
@@ -25,2 +25,6 @@ { | ||
"default": false | ||
}, | ||
"group": { | ||
"type": "string", | ||
"description": "Dependency Group" | ||
} | ||
@@ -27,0 +31,0 @@ }, |
@@ -7,3 +7,2 @@ "use strict"; | ||
const update_dependency_1 = require("../../dependency/update-dependency"); | ||
const executor_1 = require("../update/executor"); | ||
const poetry_1 = require("../utils/poetry"); | ||
@@ -19,3 +18,3 @@ function executor(options, context) { | ||
if (options.local) { | ||
const dependencyConfig = (0, executor_1.getLocalDependencyConfig)(context, options.name); | ||
const dependencyConfig = (0, poetry_1.getLocalDependencyConfig)(context, options.name); | ||
const pyprojectTomlPath = (0, poetry_1.getProjectTomlPath)(dependencyConfig); | ||
@@ -22,0 +21,0 @@ const { tool: { poetry: { name }, }, } = (0, poetry_1.parseToml)(pyprojectTomlPath); |
@@ -1,2 +0,2 @@ | ||
import { ExecutorContext, ProjectConfiguration } from '@nrwl/devkit'; | ||
import { ExecutorContext } from '@nrwl/devkit'; | ||
import { UpdateExecutorSchema } from './schema'; | ||
@@ -6,3 +6,1 @@ export default function executor(options: UpdateExecutorSchema, context: ExecutorContext): Promise<{ | ||
}>; | ||
export declare function updateLocalProject(context: ExecutorContext, dependencyName: string, projectConfig: ProjectConfiguration, updateLockOnly: boolean): void; | ||
export declare function getLocalDependencyConfig(context: ExecutorContext, dependencyName: string): ProjectConfiguration; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLocalDependencyConfig = exports.updateLocalProject = void 0; | ||
const tslib_1 = require("tslib"); | ||
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk")); | ||
const path_1 = (0, tslib_1.__importDefault)(require("path")); | ||
const poetry_1 = require("../utils/poetry"); | ||
@@ -58,16 +56,6 @@ const child_process_1 = require("child_process"); | ||
function updateLocalProject(context, dependencyName, projectConfig, updateLockOnly) { | ||
const dependencyConfig = getLocalDependencyConfig(context, dependencyName); | ||
const dependencyPath = path_1.default.relative(projectConfig.root, dependencyConfig.root); | ||
const dependencyPkgName = (0, poetry_1.addLocalProjectToPoetryProject)(projectConfig, dependencyConfig, dependencyPath); | ||
(0, poetry_1.updateProject)(dependencyPkgName, projectConfig.root, updateLockOnly); | ||
const dependencyConfig = (0, poetry_1.getLocalDependencyConfig)(context, dependencyName); | ||
const dependencyProjectToml = (0, poetry_1.parseToml)((0, poetry_1.getProjectTomlPath)(dependencyConfig)); | ||
(0, poetry_1.updateProject)(dependencyProjectToml.tool.poetry.name, projectConfig.root, updateLockOnly); | ||
} | ||
exports.updateLocalProject = updateLocalProject; | ||
function getLocalDependencyConfig(context, dependencyName) { | ||
const dependencyConfig = context.workspace.projects[dependencyName]; | ||
if (!dependencyConfig) { | ||
throw new Error((0, chalk_1.default) `project {bold ${dependencyName}} not found in the Nx workspace`); | ||
} | ||
return dependencyConfig; | ||
} | ||
exports.getLocalDependencyConfig = getLocalDependencyConfig; | ||
//# sourceMappingURL=executor.js.map |
@@ -1,5 +0,7 @@ | ||
import { ProjectConfiguration } from '@nrwl/devkit'; | ||
export declare function addLocalProjectToPoetryProject(targetConfig: ProjectConfiguration, dependencyConfig: ProjectConfiguration, dependencyPath: string): string; | ||
import { ExecutorContext, ProjectConfiguration } from '@nrwl/devkit'; | ||
import { PyprojectToml } from '../../graph/dependency-graph'; | ||
export declare function addLocalProjectToPoetryProject(targetConfig: ProjectConfiguration, dependencyConfig: ProjectConfiguration, dependencyPath: string, group?: string): string; | ||
export declare function updateProject(projectName: string, cwd: string, updateLockOnly: boolean): void; | ||
export declare function getProjectTomlPath(targetConfig: ProjectConfiguration): string; | ||
export declare function parseToml(tomlFile: string): any; | ||
export declare function parseToml(tomlFile: string): PyprojectToml; | ||
export declare function getLocalDependencyConfig(context: ExecutorContext, dependencyName: string): ProjectConfiguration; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseToml = exports.getProjectTomlPath = exports.updateProject = exports.addLocalProjectToPoetryProject = void 0; | ||
exports.getLocalDependencyConfig = exports.parseToml = exports.getProjectTomlPath = exports.updateProject = exports.addLocalProjectToPoetryProject = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -10,3 +10,3 @@ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk")); | ||
const fs_1 = (0, tslib_1.__importDefault)(require("fs")); | ||
function addLocalProjectToPoetryProject(targetConfig, dependencyConfig, dependencyPath) { | ||
function addLocalProjectToPoetryProject(targetConfig, dependencyConfig, dependencyPath, group) { | ||
const targetToml = getProjectTomlPath(targetConfig); | ||
@@ -17,6 +17,16 @@ const dependencyToml = getProjectTomlPath(dependencyConfig); | ||
const dependencyName = dependencyTomlData.tool.poetry.name; | ||
targetTomlData.tool.poetry.dependencies[dependencyName] = { | ||
path: dependencyPath, | ||
develop: true, | ||
}; | ||
if (group) { | ||
targetTomlData.tool.poetry.group = targetTomlData.tool.poetry.group || {}; | ||
targetTomlData.tool.poetry.group[group] = targetTomlData.tool.poetry.group[group] || { dependencies: {} }; | ||
targetTomlData.tool.poetry.group[group].dependencies[dependencyName] = { | ||
path: dependencyPath, | ||
develop: true, | ||
}; | ||
} | ||
else { | ||
targetTomlData.tool.poetry.dependencies[dependencyName] = { | ||
path: dependencyPath, | ||
develop: true, | ||
}; | ||
} | ||
fs_1.default.writeFileSync(targetToml, toml_1.default.stringify(targetTomlData)); | ||
@@ -43,7 +53,13 @@ return dependencyName; | ||
function parseToml(tomlFile) { | ||
return toml_1.default.parse(fs_1.default.readFileSync(tomlFile, 'utf-8') | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
); | ||
return toml_1.default.parse(fs_1.default.readFileSync(tomlFile, 'utf-8')); | ||
} | ||
exports.parseToml = parseToml; | ||
function getLocalDependencyConfig(context, dependencyName) { | ||
const dependencyConfig = context.workspace.projects[dependencyName]; | ||
if (!dependencyConfig) { | ||
throw new Error((0, chalk_1.default) `project {bold ${dependencyName}} not found in the Nx workspace`); | ||
} | ||
return dependencyConfig; | ||
} | ||
exports.getLocalDependencyConfig = getLocalDependencyConfig; | ||
//# sourceMappingURL=poetry.js.map |
@@ -21,2 +21,3 @@ import { ProjectGraph, ProjectGraphProcessorContext, Workspace, WorkspaceJsonConfiguration } from '@nrwl/devkit'; | ||
poetry: { | ||
name: string; | ||
packages: Array<{ | ||
@@ -23,0 +24,0 @@ include: string; |
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
Sorry, the diff of this file is not supported yet
146573
1568