diff --git a/packages/nx-deno-deploy/executors.json b/packages/nx-deno-deploy/executors.json index 10d04a7..25ab306 100644 --- a/packages/nx-deno-deploy/executors.json +++ b/packages/nx-deno-deploy/executors.json @@ -1,20 +1,25 @@ { - "$schema": "http://json-schema.org/schema", - "executors": { - "serve": { - "implementation": "./src/executors/serve/executor", - "schema": "./src/executors/serve/schema.json", - "description": "Run Deno project locally" - }, - "test": { - "implementation": "./src/executors/test/executor", - "schema": "./src/executors/test/schema.json", - "description": "Test Deno project" - }, - "deploy": { - "implementation": "./src/executors/deploy/executor", - "schema": "./src/executors/deploy/schema.json", - "description": "Deno deploy executor" + "$schema": "http://json-schema.org/schema", + "executors": { + "serve": { + "implementation": "./src/executors/serve/executor", + "schema": "./src/executors/serve/schema.json", + "description": "Run Deno project locally" + }, + "test": { + "implementation": "./src/executors/test/executor", + "schema": "./src/executors/test/schema.json", + "description": "Test Deno project" + }, + "lint": { + "implementation": "./src/executors/lint/executor", + "schema": "./src/executors/lint/schema.json", + "description": "Lint Deno project" + }, + "deploy": { + "implementation": "./src/executors/deploy/executor", + "schema": "./src/executors/deploy/schema.json", + "description": "Deno deploy executor" + } } - } } diff --git a/packages/nx-deno-deploy/src/executors/serve/executor.ts b/packages/nx-deno-deploy/src/executors/serve/executor.ts index e9fa177..4f52f45 100644 --- a/packages/nx-deno-deploy/src/executors/serve/executor.ts +++ b/packages/nx-deno-deploy/src/executors/serve/executor.ts @@ -1,10 +1,9 @@ -import { ExecutorContext } from '@nrwl/devkit'; +import { ExecutorContext, readProjectConfiguration } from '@nrwl/devkit'; import { FsTree } from '@nrwl/tao/src/shared/tree'; -import { readProjectConfiguration } from '@nrwl/devkit'; import { runProject } from '../../lib/deploy-ctl'; export default async function serveExecutor( - options: any, + options: unknown, context: ExecutorContext ) { const { projectName, target } = context; diff --git a/packages/nx-deno-deploy/src/executors/test/executor.ts b/packages/nx-deno-deploy/src/executors/test/executor.ts index a508099..4382193 100644 --- a/packages/nx-deno-deploy/src/executors/test/executor.ts +++ b/packages/nx-deno-deploy/src/executors/test/executor.ts @@ -4,7 +4,7 @@ import { readProjectConfiguration } from '@nrwl/devkit'; import { testProject } from '../../lib/deploy-ctl'; export default async function testExecutor( - options: any, + options: unknown, context: ExecutorContext ) { const { projectName } = context; diff --git a/packages/nx-deno-deploy/src/generators/add-targets/generator.ts b/packages/nx-deno-deploy/src/generators/add-targets/generator.ts index 555a533..d71abed 100644 --- a/packages/nx-deno-deploy/src/generators/add-targets/generator.ts +++ b/packages/nx-deno-deploy/src/generators/add-targets/generator.ts @@ -15,8 +15,11 @@ export default async function ( console.log('Adding serve, test and deploy target to ' + appName); const projectConfiguration = readProjectConfiguration(tree, appName); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { build, ...targets } = projectConfiguration.targets; + projectConfiguration.targets = { - ...projectConfiguration.targets, + ...targets, serve: { executor: '@k11r/nx-deno-deploy:serve', options: { @@ -27,6 +30,9 @@ export default async function ( test: { executor: '@k11r/nx-deno-deploy:test', }, + lint: { + executor: '@k11r/nx-deno-deploy:lint', + }, deploy: { executor: '@k11r/nx-deno-deploy:deploy', options: { diff --git a/packages/nx-deno-deploy/src/generators/create-project/index.ts b/packages/nx-deno-deploy/src/generators/create-project/index.ts index b48aaaa..c3c00ab 100644 --- a/packages/nx-deno-deploy/src/generators/create-project/index.ts +++ b/packages/nx-deno-deploy/src/generators/create-project/index.ts @@ -1,8 +1,8 @@ import { Tree, formatFiles, - installPackagesTask, generateFiles, + installPackagesTask, joinPathFragments, readProjectConfiguration, } from '@nrwl/devkit'; @@ -23,7 +23,19 @@ export default async function (tree: Tree, schema: CreateDenoProjectSchema) { tree.listChanges() .filter((fileChange) => fileChange.type === 'CREATE') .forEach((fileChange) => { - tree.delete(fileChange.path); + if ( + [ + 'tsconfig', + '.eslintrc', + 'jest', + 'package.json', + 'assets/', + 'main.ts', + '-e2e/', // TODO add e2e config + ].some((str) => fileChange.path.includes(str)) + ) { + tree.delete(fileChange.path); + } }); generateFiles(tree, joinPathFragments(__dirname, './files'), projectRoot, { diff --git a/packages/nx-deno-deploy/src/lib/deploy-ctl.ts b/packages/nx-deno-deploy/src/lib/deploy-ctl.ts index a13b2f0..24d1f03 100644 --- a/packages/nx-deno-deploy/src/lib/deploy-ctl.ts +++ b/packages/nx-deno-deploy/src/lib/deploy-ctl.ts @@ -67,6 +67,22 @@ export function testProject(sourceRoot: string) { } } +export function lintProject(sourceRoot: string) { + if (!isDenoAvailable()) { + throw new Error(`Deno is not installed.`); + } + + const command = `${denoCommand} lint`; + + try { + console.log(command); + execSync(command, { cwd: sourceRoot }); + return { success: true }; + } catch (e) { + return { success: false, error: e.toString() }; + } +} + export function runProject( mainFile: string, sourceRoot: string,