Skip to content

Commit

Permalink
chore(nx-python): remove deprecated property and replace with `contex…
Browse files Browse the repository at this point in the history
…t.projectsConfigurations`
  • Loading branch information
Cammisuli committed Oct 6, 2024
1 parent cee951b commit 056e0dd
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/nx-python/src/dependency/update-dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function updateDependencyTree(context: ExecutorContext) {

updateDependents(
context,
context.workspace,
context.projectsConfigurations,
context.projectName,
rootPyprojectToml,
context.root,
Expand Down Expand Up @@ -79,7 +79,7 @@ export function updateDependents(
}

function getProjectPackageName(context: ExecutorContext, projectName: string) {
const projectConfig = context.workspace.projects[projectName];
const projectConfig = context.projectsConfigurations.projects[projectName];
const projectToml = getProjectTomlPath(projectConfig);
const {
tool: {
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/add/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export default async function executor(
try {
activateVenv(workspaceRoot);
await checkPoetryExecutable();
const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];
const rootPyprojectToml = existsSync('pyproject.toml');

if (options.local) {
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/build/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export default async function executor(
chalk`\n {bold Building project {bgBlue ${context.projectName} }...}\n`,
);

const { root } = context.workspace.projects[context.projectName];
const { root } =
context.projectsConfigurations.projects[context.projectName];

const buildFolderPath = join(tmpdir(), 'nx-python', 'build', uuid());

Expand Down
4 changes: 3 additions & 1 deletion packages/nx-python/src/executors/build/resolvers/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ export class ProjectDependencyResolver {
}

private getProjectConfig(root: string) {
for (const [, config] of Object.entries(this.context.workspace.projects)) {
for (const [, config] of Object.entries(
this.context.projectsConfigurations.projects,
)) {
if (normalize(config.root) === normalize(root)) {
return config;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/flake8/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default async function executor(
chalk`\n {bold Running flake8 linting on project {bgBlue ${context.projectName} }...}\n`,
);

const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];
const cwd = projectConfig.root;

const absPath = path.resolve(options.outputFile);
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/install/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default async function executor(
process.chdir(workspaceRoot);
try {
await checkPoetryExecutable();
const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];
let verboseArg = '-v';

if (options.debug) {
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/remove/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default async function executor(
activateVenv(workspaceRoot);
await checkPoetryExecutable();
const rootPyprojectToml = existsSync('pyproject.toml');
const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];
console.log(
chalk`\n {bold Removing {bgBlue ${options.name} } dependency...}\n`,
);
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/ruff-check/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default async function executor(
chalk`\n{bold Running ruff check on project {bgBlue ${context.projectName} }...}\n`,
);

const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];

const commandArgs = ['run', 'ruff', 'check']
.concat(options.lintFilePatterns)
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/sls-deploy/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default async function executor(
process.chdir(workspaceRoot);
activateVenv(workspaceRoot);

const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];
const cwd = projectConfig.root;
const requirementsTxt = path.join(cwd, 'requirements.txt');

Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/sls-package/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default async function executor(
process.chdir(workspaceRoot);
activateVenv(workspaceRoot);

const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];
const cwd = projectConfig.root;
const requirementsTxt = path.join(cwd, 'requirements.txt');

Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/tox/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default async function executor(
try {
activateVenv(workspaceRoot);
await checkPoetryExecutable();
const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];
const distFolder = path.join(projectConfig.root, 'dist');

const buildResult = await buildExecutor(
Expand Down
5 changes: 3 additions & 2 deletions packages/nx-python/src/executors/update/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default async function executor(
try {
activateVenv(workspaceRoot);
await checkPoetryExecutable();
const projectConfig = context.workspace.projects[context.projectName];
const projectConfig =
context.projectsConfigurations.projects[context.projectName];
const rootPyprojectToml = existsSync('pyproject.toml');

if (options.local && options.name) {
Expand All @@ -29,7 +30,7 @@ export default async function executor(
);

if (
!Object.keys(context.workspace.projects).some(
!Object.keys(context.projectsConfigurations.projects).some(
(projectName) => options.name === projectName,
)
) {
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-python/src/executors/utils/poetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export function getLocalDependencyConfig(
context: ExecutorContext,
dependencyName: string,
) {
const dependencyConfig = context.workspace.projects[dependencyName];
const dependencyConfig =
context.projectsConfigurations.projects[dependencyName];
if (!dependencyConfig) {
throw new Error(
chalk`project {bold ${dependencyName}} not found in the Nx workspace`,
Expand Down

0 comments on commit 056e0dd

Please sign in to comment.