Skip to content

Commit

Permalink
fix: block lockfile behind flag until it's ready
Browse files Browse the repository at this point in the history
  • Loading branch information
EladBezalel committed Jan 2, 2024
1 parent 684b4b2 commit 95b507a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libs/core/src/true-affected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const trueAffected = async ({
base = 'origin/main',
projects,
include = [DEFAULT_INCLUDE_TEST_FILES],
__experimentalLockfileCheck = false,
}: TrueAffected) => {
const project = new Project({
compilerOptions: {
Expand Down Expand Up @@ -87,7 +88,7 @@ export const trueAffected = async ({
);

let changedFilesByLockfile: ChangedFiles[] = [];
if (hasLockfileChanged(changedFiles)) {
if (__experimentalLockfileCheck && hasLockfileChanged(changedFiles)) {
changedFilesByLockfile = findAffectedFilesByLockfile(
cwd,
base,
Expand Down
3 changes: 3 additions & 0 deletions libs/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ export interface TrueAffected {
base?: string;
projects: TrueAffectedProject[];
include?: (string | RegExp)[];

// **experimental** - this is an experimental feature and may be removed or changed at any time
__experimentalLockfileCheck?: boolean;
}
10 changes: 10 additions & 0 deletions libs/nx/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const affectedAction = async ({
tsConfigFilePath,
includeFiles,
target,
experimentalLockfileCheck,
}: AffectedOptions) => {
let projects = await getNxTrueAffectedProjects(cwd);

Expand All @@ -44,6 +45,7 @@ export const affectedAction = async ({
base,
projects,
include: [...includeFiles, DEFAULT_INCLUDE_TEST_FILES],
__experimentalLockfileCheck: experimentalLockfileCheck,
});

if (json) {
Expand Down Expand Up @@ -91,6 +93,7 @@ interface AffectedOptions {
includeFiles: string[];
restArgs: string[];
target: string[];
experimentalLockfileCheck?: boolean;
}

const affectedCommand: CommandModule<unknown, AffectedOptions> = {
Expand Down Expand Up @@ -138,6 +141,11 @@ const affectedCommand: CommandModule<unknown, AffectedOptions> = {
return array.flatMap((v) => v.split(',')).map((v) => v.trim());
},
},
experimentalLockfileCheck: {
desc: 'Experimental lockfile check',
type: 'boolean',
default: false,
},
},
handler: async ({
cwd,
Expand All @@ -148,6 +156,7 @@ const affectedCommand: CommandModule<unknown, AffectedOptions> = {
json,
includeFiles,
target,
experimentalLockfileCheck,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
$0,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand All @@ -163,6 +172,7 @@ const affectedCommand: CommandModule<unknown, AffectedOptions> = {
json,
includeFiles,
target,
experimentalLockfileCheck,
restArgs: Object.entries(rest).map(
/* istanbul ignore next */
([key, value]) => `--${key}=${value}`
Expand Down

0 comments on commit 95b507a

Please sign in to comment.