Skip to content

Commit

Permalink
Adding paths to TaskContext and updating all tasks to use it (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
carakessler committed May 27, 2020
1 parent 375c72f commit 8f88c8b
Show file tree
Hide file tree
Showing 38 changed files with 708 additions and 502 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ describe('octane-migration-status-task', () => {
});

project.writeSync();

let task = new OctaneMigrationStatusTask(
pluginName,
getTaskContext({}, { cwd: project.baseDir })
getTaskContext({ cliFlags: { cwd: project.baseDir }, paths: project.filePaths })
);
let taskResult = await task.run();
let { results, errorCount } = taskResult.esLintReport;

expect(results).toHaveLength(2);
expect(results).toHaveLength(3);
expect(errorCount).toBe(0);
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as globby from 'globby';

import {
BaseTask,
Category,
Expand All @@ -15,6 +13,8 @@ import { OCTANE_ES_LINT_CONFIG, OCTANE_TEMPLATE_LINT_CONFIG } from '../utils/lin

import OctaneMigrationStatusTaskResult from '../results/octane-migration-status-task-result';

const micromatch = require('micromatch');

export default class OctaneMigrationStatusTask extends BaseTask implements Task {
meta = {
taskName: 'octane-migration-status',
Expand Down Expand Up @@ -58,12 +58,14 @@ export default class OctaneMigrationStatusTask extends BaseTask implements Task
}

private async runEsLint(): Promise<ESLintReport> {
return this.eslintParser.execute([`${this.rootPath}/+(app|addon)/**/*.js`]);
let jsPaths = micromatch(this.context.paths, '**/*.js');

return this.eslintParser.execute(jsPaths);
}

private async runTemplateLint(): Promise<TemplateLintReport> {
let paths = await globby(`${this.rootPath}/+(app|addon)/**/*.hbs`);
let hbsPaths = micromatch(this.context.paths, '**/*.hbs');

return this.templateLinter.execute(paths);
return this.templateLinter.execute(hbsPaths);
}
}
Original file line number Diff line number Diff line change
@@ -1,110 +1,68 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`types-task returns all the types (including nested) found in the app and outputs to JSON 1`] = `
Object {
"meta": Object {
"friendlyTaskName": "Ember Types",
"taskClassification": Object {
"category": "insights",
"priority": "high",
},
"taskName": "ember-types",
},
"result": Object {
"types": Array [
Object {
"data": Array [
"addon/components/my-component.js",
"lib/ember-super-button/addon/components/my-component.js",
],
"displayName": "Components",
"total": 2,
"type": "components",
},
Object {
"data": Array [
"addon/controllers/my-controller.js",
"lib/ember-super-button/addon/controllers/my-controller.js",
],
"displayName": "Controllers",
"total": 2,
"type": "controllers",
},
Object {
"data": Array [
"addon/helpers/my-helper.js",
"lib/ember-super-button/addon/helpers/my-helper.js",
],
"displayName": "Helpers",
"total": 2,
"type": "helpers",
},
Object {
"data": Array [
"addon/initializers/my-initializer.js",
"lib/ember-super-button/addon/initializers/my-initializer.js",
],
"displayName": "Initializers",
"total": 2,
"type": "initializers",
},
Object {
"data": Array [
"addon/instance-initializers/my-helper.js",
"lib/ember-super-button/addon/instance-initializers/my-helper.js",
],
"displayName": "Instance Initializers",
"total": 2,
"type": "instance-initializers",
},
Object {
"data": Array [
"addon/mixins/my-mixin.js",
"lib/ember-super-button/addon/mixins/my-mixin.js",
],
"displayName": "Mixins",
"total": 2,
"type": "mixins",
},
Object {
"data": Array [
"addon/models/my-model.js",
"lib/ember-super-button/addon/models/my-model.js",
],
"displayName": "Models",
"total": 2,
"type": "models",
},
Object {
"data": Array [
"addon/routes/my-route.js",
"lib/ember-super-button/addon/routes/my-route.js",
],
"displayName": "Routes",
"total": 2,
"type": "routes",
},
Object {
"data": Array [
"addon/services/my-service.js",
"lib/ember-super-button/addon/services/my-service.js",
],
"displayName": "Services",
"total": 2,
"type": "services",
},
Object {
"data": Array [
"addon/templates/my-component.hbs",
"lib/ember-super-button/addon/templates/my-component.hbs",
],
"displayName": "Templates",
"total": 2,
"type": "templates",
},
],
},
}
Array [
Object {
"data": Array [],
"displayName": "Components",
"total": 2,
"type": "components",
},
Object {
"data": Array [],
"displayName": "Controllers",
"total": 2,
"type": "controllers",
},
Object {
"data": Array [],
"displayName": "Helpers",
"total": 2,
"type": "helpers",
},
Object {
"data": Array [],
"displayName": "Initializers",
"total": 2,
"type": "initializers",
},
Object {
"data": Array [],
"displayName": "Instance Initializers",
"total": 2,
"type": "instance-initializers",
},
Object {
"data": Array [],
"displayName": "Mixins",
"total": 2,
"type": "mixins",
},
Object {
"data": Array [],
"displayName": "Models",
"total": 2,
"type": "models",
},
Object {
"data": Array [],
"displayName": "Routes",
"total": 2,
"type": "routes",
},
Object {
"data": Array [],
"displayName": "Services",
"total": 2,
"type": "services",
},
Object {
"data": Array [],
"displayName": "Templates",
"total": 2,
"type": "templates",
},
]
`;

exports[`types-task returns all the types (including nested) found in the app and outputs to the console 1`] = `
Expand All @@ -126,100 +84,68 @@ Templates 2
`;

exports[`types-task returns all the types found in the app and outputs to JSON 1`] = `
Object {
"meta": Object {
"friendlyTaskName": "Ember Types",
"taskClassification": Object {
"category": "insights",
"priority": "high",
},
"taskName": "ember-types",
},
"result": Object {
"types": Array [
Object {
"data": Array [
"addon/components/my-component.js",
],
"displayName": "Components",
"total": 1,
"type": "components",
},
Object {
"data": Array [
"addon/controllers/my-controller.js",
],
"displayName": "Controllers",
"total": 1,
"type": "controllers",
},
Object {
"data": Array [
"addon/helpers/my-helper.js",
],
"displayName": "Helpers",
"total": 1,
"type": "helpers",
},
Object {
"data": Array [
"addon/initializers/my-initializer.js",
],
"displayName": "Initializers",
"total": 1,
"type": "initializers",
},
Object {
"data": Array [
"addon/instance-initializers/my-helper.js",
],
"displayName": "Instance Initializers",
"total": 1,
"type": "instance-initializers",
},
Object {
"data": Array [
"addon/mixins/my-mixin.js",
],
"displayName": "Mixins",
"total": 1,
"type": "mixins",
},
Object {
"data": Array [
"addon/models/my-model.js",
],
"displayName": "Models",
"total": 1,
"type": "models",
},
Object {
"data": Array [
"addon/routes/my-route.js",
],
"displayName": "Routes",
"total": 1,
"type": "routes",
},
Object {
"data": Array [
"addon/services/my-service.js",
],
"displayName": "Services",
"total": 1,
"type": "services",
},
Object {
"data": Array [
"addon/templates/my-component.hbs",
],
"displayName": "Templates",
"total": 1,
"type": "templates",
},
],
},
}
Array [
Object {
"data": Array [],
"displayName": "Components",
"total": 1,
"type": "components",
},
Object {
"data": Array [],
"displayName": "Controllers",
"total": 1,
"type": "controllers",
},
Object {
"data": Array [],
"displayName": "Helpers",
"total": 1,
"type": "helpers",
},
Object {
"data": Array [],
"displayName": "Initializers",
"total": 1,
"type": "initializers",
},
Object {
"data": Array [],
"displayName": "Instance Initializers",
"total": 1,
"type": "instance-initializers",
},
Object {
"data": Array [],
"displayName": "Mixins",
"total": 1,
"type": "mixins",
},
Object {
"data": Array [],
"displayName": "Models",
"total": 1,
"type": "models",
},
Object {
"data": Array [],
"displayName": "Routes",
"total": 1,
"type": "routes",
},
Object {
"data": Array [],
"displayName": "Services",
"total": 1,
"type": "services",
},
Object {
"data": Array [],
"displayName": "Templates",
"total": 1,
"type": "templates",
},
]
`;

exports[`types-task returns all the types found in the app and outputs to the console 1`] = `
Expand Down
Loading

0 comments on commit 8f88c8b

Please sign in to comment.