Skip to content

Commit

Permalink
Lab #14
Browse files Browse the repository at this point in the history
  • Loading branch information
christianliebel committed Oct 7, 2024
1 parent 979b1ba commit 4229c73
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 2 deletions.
8 changes: 7 additions & 1 deletion tools/my-plugin/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ module.exports = [
},
},
{
files: ['**/package.json', '**/package.json', '**/generators.json'],
files: [
'**/package.json',
'**/generators.json',
'**/package.json',
'**/generators.json',
'**/executors.json',
],
rules: {
'@nx/nx-plugin-checks': 'error',
},
Expand Down
9 changes: 9 additions & 0 deletions tools/my-plugin/executors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"executors": {
"echo": {
"implementation": "./src/executors/echo/executor",
"schema": "./src/executors/echo/schema.json",
"description": "echo executor"
}
}
}
3 changes: 2 additions & 1 deletion tools/my-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"private": true,
"generators": "./generators.json"
"generators": "./generators.json",
"executors": "./executors.json"
}
18 changes: 18 additions & 0 deletions tools/my-plugin/src/executors/echo/executor.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ExecutorContext } from '@nx/devkit';

import { EchoExecutorSchema } from './schema';
import executor from './executor';

const options: EchoExecutorSchema = {};
const context: ExecutorContext = {
root: '',
cwd: process.cwd(),
isVerbose: false,
};

describe('Echo Executor', () => {
it('can run', async () => {
const output = await executor(options, context);
expect(output.success).toBe(true);
});
});
11 changes: 11 additions & 0 deletions tools/my-plugin/src/executors/echo/executor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { PromiseExecutor } from '@nx/devkit';
import { EchoExecutorSchema } from './schema';

const runExecutor: PromiseExecutor<EchoExecutorSchema> = async (options) => {
console.log('Executor ran for Echo', options);
return {
success: true,
};
};

export default runExecutor;
1 change: 1 addition & 0 deletions tools/my-plugin/src/executors/echo/schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface EchoExecutorSchema {} // eslint-disable-line
9 changes: 9 additions & 0 deletions tools/my-plugin/src/executors/echo/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/schema",
"version": 2,
"title": "Echo executor",
"description": "",
"type": "object",
"properties": {},
"required": []
}

0 comments on commit 4229c73

Please sign in to comment.