Skip to content

Commit ea9f471

Browse files
committed
Add project files
Signed-off-by: macdonst <simon.macdonald@gmail.com>
0 parents  commit ea9f471

File tree

11 files changed

+258
-0
lines changed

11 files changed

+258
-0
lines changed

.arc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@app
2+
enhance-app
3+
4+
@plugins
5+
enhance/arc-plugin-enhance
6+
enhance/arc-plugin-styles
7+
enhance/styles-cribsheet
8+
enhance/plugin-typescript

.github/workflows/CI.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Node CI
2+
3+
# Push tests pushes; PR tests merges
4+
on: [ push, pull_request ]
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
# Run tests on PR branches
12+
build_prs:
13+
name: Run tests on PR branch
14+
if: github.ref != 'refs/heads/main' || github.event_name == 'pull_request'
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check out repo
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
24+
- name: Install
25+
run: npm install
26+
27+
- name: Typescript compile
28+
run: tsc
29+
30+
- name: Run tests
31+
run: npm run test
32+
33+
# Deploy the build
34+
deploy_staging:
35+
name: Deploy staging
36+
if: github.ref == 'refs/heads/main' && github.event_name == 'push' # Don't run twice for PRs (for now)
37+
runs-on: ubuntu-latest
38+
concurrency:
39+
group: staging_${{ github.repository }}
40+
41+
steps:
42+
- name: Check out repo
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Node.js
46+
uses: actions/setup-node@v4
47+
48+
- name: Install
49+
run: npm install
50+
51+
- name: Typescript compile
52+
run: tsc
53+
54+
- name: Run tests
55+
run: npm run test
56+
57+
- name: Deploy to staging
58+
uses: beginner-corp/actions/deploy@main
59+
with:
60+
begin_token: ${{ secrets.BEGIN_TOKEN }}
61+
begin_env_name: staging
62+
channel: 'main'
63+
64+
# Deploy the build
65+
deploy_production:
66+
name: Deploy production
67+
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push' # Don't run twice for PRs (for now)
68+
runs-on: ubuntu-latest
69+
concurrency:
70+
group: production_${{ github.repository }}
71+
72+
steps:
73+
- name: Check out repo
74+
uses: actions/checkout@v4
75+
76+
- name: Set up Node.js
77+
uses: actions/setup-node@v4
78+
79+
- name: Install
80+
run: npm install
81+
82+
- name: Typescript compile
83+
run: tsc
84+
85+
- name: Run tests
86+
run: npm run test
87+
88+
- name: Deploy to production
89+
uses: beginner-corp/actions/deploy@main
90+
with:
91+
begin_token: ${{ secrets.BEGIN_TOKEN }}
92+
begin_env_name: production
93+
channel: 'main'

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# .gitignore for this template project
2+
# template.gitignore should be used by generated projects
3+
node_modules/
4+
manifest.json
5+
package-lock.json
6+
.DS_Store
7+
.enhance/
8+
public/static.json

package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@enhance/starter-typescript",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"start": "enhance dev",
6+
"dev": "enhance dev",
7+
"build": "tsc",
8+
"enhance": "enhance",
9+
"test": "echo \"Warning: no test specified\" && exit 0"
10+
},
11+
"dependencies": {
12+
"@enhance/arc-plugin-enhance": "^11.0.1",
13+
"@enhance/arc-plugin-styles": "^5.0.6",
14+
"@enhance/plugin-typescript": "^0.1.0",
15+
"@enhance/styles-cribsheet": "^0.0.11"
16+
},
17+
"devDependencies": {
18+
"@enhance/cli": "latest",
19+
"@enhance/types": "^0.7.0",
20+
"typescript": "^5.4.5"
21+
}
22+
}

readme.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
![enhance-type](https://user-images.githubusercontent.com/76308/223593101-1f65f07f-49c4-4a13-9203-4ab4ff72f097.svg)
2+
3+
# `@enhance/enhance-starter-typescript`
4+
5+
This is the repo containing the Typescript starter project that is generated by the [Enhance CLI](https://www.npmjs.com/package/@enhance/cli)
6+
7+
## Quick start
8+
9+
```sh
10+
npx "@enhance/cli@latest" new ./myproject --template https://github.com/enhance-dev/enhance-starter-typescript -y
11+
```
12+
13+
⚠️ This repo is **not** meant to be cloned unless you are filing an issue or adding functionality. It is meant to be used by the generators linked above instead.
14+
15+
## Project structure
16+
17+
```
18+
ts
19+
├── api ............... data routes
20+
│ └── index.mjs
21+
├── browser ........... browser JavaScript
22+
│ └── index.mjs
23+
├── elements .......... Custom Element pure functions
24+
│ └── my-header.mjs
25+
└── pages ............. file-based routing
26+
└── index.html
27+
28+
```
29+
[Read the documentation here →](https://enhance.dev)

template.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
node_modules/
2+
.env
3+
4+
# Enhance temp files
5+
.enhance/
6+
7+
# Generated assets
8+
public/static.json
9+
public/browser/
10+
public/bundles/
11+
public/pages/
12+
13+
# Architect CloudFormation
14+
sam.json
15+
sam.yaml
16+
17+
.DS_Store

ts/api/typescripted.mts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type {
2+
EnhanceApiFn,
3+
EnhanceApiReq,
4+
EnhanceApiRes,
5+
} from "@enhance/types";
6+
7+
type Todo = {
8+
title: string;
9+
completed?: boolean;
10+
};
11+
12+
export const get: EnhanceApiFn = async function (
13+
request: EnhanceApiReq,
14+
): Promise<EnhanceApiRes> {
15+
console.log(`Handling ${request.path}...`);
16+
17+
const todos: Todo[] = [
18+
{ title: "todo 1", completed: false },
19+
{ title: "todo 2", completed: true },
20+
{ title: "todo 3" },
21+
];
22+
23+
const response: EnhanceApiRes = {
24+
json: { todos },
25+
};
26+
27+
return response;
28+
};

ts/elements/typescript-todo.mts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { EnhanceElemArg } from "@enhance/types"
2+
3+
export default ({ html, state: { attrs } }: EnhanceElemArg) => {
4+
const { state = "" } = attrs
5+
6+
return html`
7+
${state === "complete" ? "☑" : "☐"}
8+
<slot></slot>
9+
`
10+
}

ts/pages/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>This page is Vanilla HTML</h1>
2+
3+
<a href="/typescripted">Go to TypeScripted</a>

ts/pages/typescripted.mts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { EnhanceElemArg } from "@enhance/types";
2+
3+
export default ({ html, state: { store } }: EnhanceElemArg) => {
4+
const { todos } = store;
5+
6+
return html`
7+
<style>
8+
ul typescript-todo {
9+
display: block;
10+
}
11+
</style>
12+
13+
<h1>Typescripted</h1>
14+
<p>This page is written in TypeScript.</p>
15+
<h2>The <code>&lt;typescript-todo&gt;</code> element is also TypeScript</h2>
16+
<h2>Even the API is TypeScript</h2>
17+
<p>Here are the TODOs:</p>
18+
<ul>
19+
${todos.map(todo => html`
20+
<typescript-todo state="${todo.completed ? "complete" : ""}">
21+
${todo.title}
22+
</typescript-todo>
23+
`).join("")}
24+
</ul>
25+
`
26+
}

tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"module": "NodeNext",
4+
"target": "ES6",
5+
"outDir": "app",
6+
"rootDir": "ts"
7+
},
8+
"include": [
9+
"ts/**/*"
10+
],
11+
"exclude": [
12+
"node_modules"
13+
]
14+
}

0 commit comments

Comments
 (0)