Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable stitch to pass arguments to tasks #6

Merged
merged 2 commits into from Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/checkup-plugin-embroider/tasks/dependency-check-task.ts
Expand Up @@ -14,22 +14,27 @@ export default class DependencyCheck extends BaseTask implements Task {
category = 'embroider';

async run(): Promise<Result[]> {
const packageCompatibility: PackageCheck = packageCompatibilityJSON;
debugger;
scalvert marked this conversation as resolved.
Show resolved Hide resolved
const packageCompatibility: PackageCheck = packageCompatibilityJSON;
const pkgs = await findBadPackages(this.context.options.cwd, packageCompatibility);
const results = [];

for (const pkg of pkgs) {
results.push({
message: { text: `Detected version of ${pkg.packageName} as ${pkg.packageVersion} but ${packageCompatibility[pkg.packageName]} found in ${pkg.packageBreadcrumb.join(' > ')}.` },
message: {
text: `Detected version of ${pkg.packageName} as ${pkg.packageVersion} but ${
packageCompatibility[pkg.packageName]
} found in ${pkg.packageBreadcrumb.join(' > ')}.`,
},
ruleId: this.taskName,
properties: {
taskDisplayName: this.taskDisplayName,
category: this.category,
stitchResult: {
packageName: pkg.packageName,
packageVersion: pkg.packageVersion,
packageBreadcrumb: pkg.packageBreadcrumb
}
packageBreadcrumb: pkg.packageBreadcrumb,
},
},
});
}
Expand Down
11 changes: 10 additions & 1 deletion src/stitch.ts
Expand Up @@ -5,6 +5,7 @@ import * as yargs from 'yargs';

interface StitchArguments {
workingDirectory: string;
fooBar: string;
}

type Options = StitchArguments & yargs.Arguments;
Expand Down Expand Up @@ -34,6 +35,10 @@ export async function run(argv: string[] = process.argv.slice(2)): Promise<void>
// are fairly deep)
default: '.',
},
'foo-bar': {
describe: 'An example of threading arguments through to tasks',
type: 'string',
},
});
},
handler: async (options: Options) => {
Expand All @@ -46,10 +51,14 @@ export async function run(argv: string[] = process.argv.slice(2)): Promise<void>
$schema: CONFIG_SCHEMA_URL,
excludePaths: [],
plugins: ['checkup-plugin-embroider'],
tasks: {},
tasks: {
'embroider/dependency-check': ['on', { fooBar: options.fooBar }],
},
};

const taskRunner = new CheckupTaskRunner({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
config,
cwd: options.workingDirectory,
pluginBaseDir: __dirname,
Expand Down