generated from mikedownesdev/gas-svelte-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7b65310
Showing
76 changed files
with
9,142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"rootDir":"dist","scriptId":"1JIjJPR-KKIYPrBK92j-meWZNw6qvDLnFeJcG1-t2QwedzYMIAacjkBhe"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Prod Env Deploy Script | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
|
||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Install clasp | ||
id: install-clasp | ||
run: sudo npm install @google/[email protected] -g | ||
|
||
- name: Write CLASPRC_JSON secret to .clasprc.json file | ||
id: write-clasprc | ||
run: echo "$CLASPRC_JSON_SECRET" >> ~/.clasprc.json | ||
env: | ||
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }} | ||
|
||
- name: Check clasp login status | ||
id: clasp_login | ||
run: clasp login --status | ||
|
||
- name: Save current .clasprc.json contents to CLASPRC_JSON_FILE environment variable | ||
id: save-clasprc | ||
run: | | ||
echo ::add-mask::$(tr -d '\n\r' < ~/.clasprc.json) | ||
echo "CLASPRC_JSON_FILE=$(tr -d '\n\r' < ~/.clasprc.json)" >> $GITHUB_ENV | ||
- name: Save CLASPRC_JSON_FILE environment variable to CLASPRC_JSON repo secret | ||
id: set-clasprc-secret | ||
if: ${{ env.CLASPRC_JSON_FILE != env.CLASPRC_JSON_SECRET }} | ||
uses: hmanzur/[email protected] | ||
env: | ||
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }} | ||
with: | ||
name: "CLASPRC_JSON" | ||
value: ${{ env.CLASPRC_JSON_FILE }} | ||
repository: ${{ github.repository }} | ||
token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
|
||
- name: Set scriptId in .clasp.json file | ||
id: set-script-id | ||
run: jq '.scriptId = "${{env.PROD_SCRIPT_ID}}"' .clasp.json > /tmp/.clasp.json && mv /tmp/.clasp.json .clasp.json | ||
env: | ||
PROD_SCRIPT_ID: ${{secrets.PROD_SCRIPT_ID}} | ||
|
||
## Build & push | ||
|
||
- name: Build project | ||
run: npm run build | ||
|
||
- name: Push script to scripts.google.com | ||
id: clasp-push | ||
run: clasp push -f | ||
|
||
- name: Deploy Script | ||
id: clasp-deploy | ||
if: github.ref == 'refs/heads/main' | ||
run: clasp deploy -i "${{ secrets.PROD_DEPLOYMENT_ID }}" -d ${{github.run_number}} | ||
env: | ||
PROD_SCRIPT_ID: ${{ secrets.PROD_SCRIPT_ID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Test Env Deploy Script | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [test] | ||
|
||
jobs: | ||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
|
||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Install clasp | ||
id: install-clasp | ||
run: sudo npm install @google/[email protected] -g | ||
|
||
- name: Write CLASPRC_JSON secret to .clasprc.json file | ||
id: write-clasprc | ||
run: echo "$CLASPRC_JSON_SECRET" >> ~/.clasprc.json | ||
env: | ||
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }} | ||
|
||
- name: Check clasp login status | ||
id: clasp_login | ||
run: clasp login --status | ||
|
||
- name: Save current .clasprc.json contents to CLASPRC_JSON_FILE environment variable | ||
id: save-clasprc | ||
run: | | ||
echo ::add-mask::$(tr -d '\n\r' < ~/.clasprc.json) | ||
echo "CLASPRC_JSON_FILE=$(tr -d '\n\r' < ~/.clasprc.json)" >> $GITHUB_ENV | ||
- name: Save CLASPRC_JSON_FILE environment variable to CLASPRC_JSON repo secret | ||
id: set-clasprc-secret | ||
if: ${{ env.CLASPRC_JSON_FILE != env.CLASPRC_JSON_SECRET }} | ||
uses: hmanzur/[email protected] | ||
env: | ||
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }} | ||
with: | ||
name: "CLASPRC_JSON" | ||
value: ${{ env.CLASPRC_JSON_FILE }} | ||
repository: ${{ github.repository }} | ||
token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
|
||
- name: Set scriptId in .clasp.json file | ||
id: set-script-id | ||
run: jq '.scriptId = "${{env.TEST_SCRIPT_ID}}"' .clasp.json > /tmp/.clasp.json && mv /tmp/.clasp.json .clasp.json | ||
env: | ||
TEST_SCRIPT_ID: ${{secrets.TEST_SCRIPT_ID}} | ||
|
||
## Build & push | ||
|
||
- name: Build project | ||
run: npm run build | ||
|
||
- name: Push script to scripts.google.com | ||
id: clasp-push | ||
run: clasp push -f | ||
|
||
- name: Deploy Script | ||
id: clasp-deploy | ||
if: github.ref == 'refs/heads/test' | ||
run: clasp deploy -i "${{ secrets.TEST_DEPLOYMENT_ID }}" -d ${{github.run_number}} | ||
env: | ||
TEST_SCRIPT_ID: ${{ secrets.TEST_SCRIPT_ID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Clasp config | ||
#**/.clasp.json | ||
|
||
# Environment variables | ||
.env | ||
|
||
# temporarily adding to ignore image assets | ||
images/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Clasp config | ||
**/.clasp.json | ||
|
||
# Environment variables | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["svelte.svelte-vscode"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# About | ||
|
||
This is a proof-of-concept project to create a template for new web | ||
applications that run on Google Apps Script. It uses... | ||
|
||
- [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) for the front end | ||
- [DaisyUI] / [TailwindCSS] for components & styling | ||
- [Google Apps Script] for the back end | ||
- [JSDoc] type definitions | ||
- [Vite] for the build process | ||
|
||
Whereas a "boilerplate" may produce the bare minimum to get a new web app off | ||
the ground, this project provides a few extra opinions, UI elements, type definitions, etc that I would consider useful for most applications, rather than just an app skeleton. | ||
|
||
# How to Use | ||
|
||
# Other Notable Dependncies | ||
|
||
- [clasp] | ||
- [clasp.env] | ||
|
||
# Features | ||
|
||
|
||
# Critical Decisions | ||
|
||
``` | ||
"timeZone": "America/New_York" | ||
``` | ||
``` | ||
"webapp": { | ||
"executeAs": "USER_DEPLOYING" vs "executeAs": "USER_ACCESSING", | ||
"access": "ANYONE" vs "access": "ANYONE_ANONYMOUS" | ||
} | ||
``` | ||
|
||
## Recommended IDE Setup | ||
|
||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) | ||
|
||
## Technical considerations | ||
|
||
**Why use this over SvelteKit?** | ||
|
||
- It brings its own routing solution which might not be preferable for some users. | ||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app. | ||
|
||
This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project. | ||
|
||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate. | ||
|
||
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?** | ||
|
||
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information. | ||
|
||
**Why include `.vscode/extensions.json`?** | ||
|
||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project. | ||
|
||
**Why enable `checkJs` in the JS template?** | ||
|
||
It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration. | ||
|
||
**Why is HMR not preserving my local component state?** | ||
|
||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/sveltejs/svelte-hmr/tree/master/packages/svelte-hmr#preservation-of-local-state). | ||
|
||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR. | ||
|
||
```js | ||
// store.js | ||
// An extremely simple external store | ||
import { writable } from 'svelte/store' | ||
export default writable(0) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" data-theme="light"> | ||
<head> | ||
<base target="_self" /> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<!-- STYLES --> | ||
<link rel="stylesheet" | ||
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" /> | ||
<link rel="shortcut icon" href="https://www.gstatic.com/script/favicon.ico" type="image/x-icon" /> | ||
<!-- /STYLES --> | ||
<title id="app-title"></title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "bundler", | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
/** | ||
* svelte-preprocess cannot figure out whether you have | ||
* a value or a type, so tell TypeScript to enforce using | ||
* `import type` instead of `import` for Types. | ||
*/ | ||
"verbatimModuleSyntax": true, | ||
"isolatedModules": true, | ||
"resolveJsonModule": true, | ||
/** | ||
* To have warnings / errors of the Svelte compiler at the | ||
* correct position, enable source maps by default. | ||
*/ | ||
"sourceMap": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
/** | ||
* Typecheck JS in `.svelte` and `.js` files by default. | ||
* Disable this if you'd like to use dynamic types. | ||
*/ | ||
"checkJs": true | ||
}, | ||
/** | ||
* Use global.d.ts instead of compilerOptions.types | ||
* to avoid limiting type declarations. | ||
*/ | ||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"] | ||
} |
Oops, something went wrong.