Skip to content

Commit

Permalink
feat: deno updates
Browse files Browse the repository at this point in the history
  • Loading branch information
klaascuvelier committed Apr 12, 2023
1 parent 5741301 commit efe981d
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 24 deletions.
39 changes: 22 additions & 17 deletions packages/nx-deno-deploy/executors.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
5 changes: 2 additions & 3 deletions packages/nx-deno-deploy/src/executors/serve/executor.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/nx-deno-deploy/src/executors/test/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down
16 changes: 14 additions & 2 deletions packages/nx-deno-deploy/src/generators/create-project/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
Tree,
formatFiles,
installPackagesTask,
generateFiles,
installPackagesTask,
joinPathFragments,
readProjectConfiguration,
} from '@nrwl/devkit';
Expand All @@ -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, {
Expand Down
16 changes: 16 additions & 0 deletions packages/nx-deno-deploy/src/lib/deploy-ctl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit efe981d

Please sign in to comment.