-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): reset should cleanup temporary nx-cloud files (#23316)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> `nx reset` doesn't remove marker files used by nx cloud. ## Expected Behavior `nx reset` removes marker files from nx cloud ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes ##23308 (cherry picked from commit b7472fd)
- Loading branch information
1 parent
9b962b6
commit ed4c5a9
Showing
6 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { findAncestorNodeModules } from '../resolution-helpers'; | ||
import { verifyOrUpdateNxCloudClient } from '../update-manager'; | ||
import { CloudTaskRunnerOptions } from '../nx-cloud-tasks-runner-shell'; | ||
|
||
export class UnknownCommandError extends Error { | ||
constructor(public command: string, public availableCommands: string[]) { | ||
super(`Unknown Command "${command}"`); | ||
} | ||
} | ||
|
||
export async function getCloudClient(options: CloudTaskRunnerOptions) { | ||
const { nxCloudClient } = await verifyOrUpdateNxCloudClient(options); | ||
|
||
const paths = findAncestorNodeModules(__dirname, []); | ||
nxCloudClient.configureLightClientRequire()(paths); | ||
|
||
return { | ||
invoke: (command: string) => { | ||
if (command in nxCloudClient.commands) { | ||
nxCloudClient.commands[command]() | ||
.then(() => process.exit(0)) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); | ||
} else { | ||
throw new UnknownCommandError( | ||
command, | ||
Object.keys(nxCloudClient.commands) | ||
); | ||
} | ||
}, | ||
availableCommands: Object.keys(nxCloudClient.commands), | ||
}; | ||
} |