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

Adding deno flavor of typescript as an app type #1629

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions templates/deno-app/.hooks.sscaff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { execSync } = require('child_process');
const { readFileSync } = require('fs');

exports.post = ctx => {

const env = { ...process.env };

// execSync('npm install', { stdio: 'inherit', env });

// // import k8s objects
// execSync('npm run import', { stdio: 'inherit', env });
// execSync('npm run compile', { stdio: 'inherit', env });
// execSync('npm run test -- -u', { stdio: 'inherit', env });
// execSync('npm run synth', { stdio: 'inherit', env });

console.log(readFileSync('./help', 'utf-8'));
};
3 changes: 3 additions & 0 deletions templates/deno-app/__snapshots__/main.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions templates/deno-app/cdk8s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: typescript
app: deno run --allow-env --allow-write --allow-read main.ts
imports:
- k8s
3 changes: 3 additions & 0 deletions templates/deno-app/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { Construct } from 'npm:constructs@^{{ constructs_version }}';
export { App, Chart } from 'npm:cdk8s@^{{ cdk8s_core_version }}';
export type { ChartProps } from 'npm:cdk8s@^{{ cdk8s_core_version }}'
23 changes: 23 additions & 0 deletions templates/deno-app/help
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
========================================================================================================

Your cdk8s typescript project is ready!

cat help Print this message

Compile:
npm run compile Compile typescript code to javascript (or "yarn watch")
npm run watch Watch for changes and compile typescript in the background
npm run build Compile + synth

Synthesize:
npm run synth Synthesize k8s manifests from charts to dist/ (ready for 'kubectl apply -f')

Deploy:
kubectl apply -f dist/

Upgrades:
npm run import Import/update k8s apis (you should check-in this directory)
npm run upgrade Upgrade cdk8s modules to latest version
npm run upgrade:next Upgrade cdk8s modules to latest "@next" version (last commit)

========================================================================================================
9 changes: 9 additions & 0 deletions templates/deno-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
"roots": [
"<rootDir>"
],
testMatch: [ '**/*.test.ts'],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
}
11 changes: 11 additions & 0 deletions templates/deno-app/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {MyChart} from './main';
import {Testing} from 'cdk8s';

describe('Placeholder', () => {
test('Empty', () => {
const app = Testing.app();
const chart = new MyChart(app, 'test-chart');
const results = Testing.synth(chart)
expect(results).toMatchSnapshot();
});
});
14 changes: 14 additions & 0 deletions templates/deno-app/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { App, Chart, ChartProps, Construct } from './deps.ts';

export class MyChart extends Chart {
constructor(scope: Construct, id: string, props: ChartProps = { }) {
super(scope, id, props);

// define resources here

}
}

const app = new App();
new MyChart(app, '{{ $base }}');
app.synth();
34 changes: 34 additions & 0 deletions templates/deno-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"compilerOptions": {
"alwaysStrict": true,
"charset": "utf8",
"declaration": true,
"experimentalDecorators": true,
"inlineSourceMap": true,
"inlineSources": true,
"lib": [
"es2016"
],
"module": "CommonJS",
"noEmit": false,
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"strict": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"stripInternal": true,
"target": "ES2017"
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules"
]
}
5 changes: 5 additions & 0 deletions templates/deno-app/{{}}.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.d.ts
*.js
!jest.config.js
node_modules
dist/
93 changes: 42 additions & 51 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading