{"id":15379932,"url":"https://github.com/iansan5653/gas-ts-template","last_synced_at":"2025-08-22T02:30:50.187Z","repository":{"id":55062381,"uuid":"257120215","full_name":"iansan5653/gas-ts-template","owner":"iansan5653","description":"📄 Template to build Google Apps Script projects with TypeScript.","archived":false,"fork":false,"pushed_at":"2025-06-06T13:57:34.000Z","size":311,"stargazers_count":50,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T05:06:55.409Z","etag":null,"topics":["clasp","eslint","gas","github-workflows","google-apps","google-apps-script","ts","typescript","typescript-files"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iansan5653.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-19T23:03:51.000Z","updated_at":"2025-06-06T13:57:36.000Z","dependencies_parsed_at":"2024-10-31T21:03:19.565Z","dependency_job_id":"ac2b7789-7550-4bc3-b8da-fc18bb2d538c","html_url":"https://github.com/iansan5653/gas-ts-template","commit_stats":{"total_commits":51,"total_committers":2,"mean_commits":25.5,"dds":"0.039215686274509776","last_synced_commit":"2b68e8ad999694adc6188b1590d5ed9fa9bedf05"},"previous_names":[],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/iansan5653/gas-ts-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansan5653%2Fgas-ts-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansan5653%2Fgas-ts-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansan5653%2Fgas-ts-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansan5653%2Fgas-ts-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iansan5653","download_url":"https://codeload.github.com/iansan5653/gas-ts-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansan5653%2Fgas-ts-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271575499,"owners_count":24783543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clasp","eslint","gas","github-workflows","google-apps","google-apps-script","ts","typescript","typescript-files"],"created_at":"2024-10-01T14:20:27.165Z","updated_at":"2025-08-22T02:30:50.178Z","avatar_url":"https://github.com/iansan5653.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Apps \u0026 TypeScript Project Template\n\nThis repository provides a simple template to start a new\n[Google Apps Script](https://developers.google.com/apps-script) project with TypeScript. Building, linting,\nformatting, and pushing to Google Apps are all built in.\n\nThe project is set up with a TypeScript configuration that transforms your TypeScript files in the `src`\ndirectory into JavaScript files in the `build` directory. It's not enough to upload those files as-is to\nGoogle Apps, however, because Apps Script doesn't support installing and running dependencies, and uploaded\nfiles are run in random order - they aren't linked together at all. To solve this problem, a second build step\nuses Webpack to combine all files and depdendencies into a single minified `Code.js` file, which is the only\nfile that is actually pushed to Google Apps.\n\n## Getting Started\n\n1. Click [\"Use This Template\"](https://github.com/iansan5653/gas-ts-template/generate) to start a new\n   repository. Clone your new repo and open a terminal in the local directory. This template includes some\n   configuration for VSCode, but you can use any editor.\n2. Ensure [Node.js](https://nodejs.org/en/) is installed on your system, then install all of the dependencies\n   by running `npm install`. Alternatively, start a Codespace in your new repository and dependencies will be\n   installed automatically.\n3. Start a new Google Apps Script project by going to https://script.google.com/home and clicking **New\n   project**. You can also start a project tied directly to a specific Google Apps file by opening the file\n   and clicking **Tools** -\u003e **Script Editor**.\n4. Click the gear icon in the Google Apps Script editor sidebar. Copy the **Script ID**.\n5. Replace `SCRIPT_ID` in [`.clasp.json`](./.clasp.json) with your project's ID. This ID is _not_ a secret -\n   you can safely commit it to your repository.\n6. Write your TypeScript code in the `src` folder. Note that `index.ts` is the entrypoint for your project.\n   Only what is imported into the `index.ts` file will be compiled into the script.\n7. Optional: lint your code with `npm run lint` and/or auto-format your code with `npm run format`. Typically\n   you will want to install the ESLint and/or Prettier extensions in your preferred code editor.\n8. Deploy your code to Google Apps:\n   - **Manually**:\n     1. Log in to Google Apps Script by running `npm run login`. Make sure to use the same account you used to\n        make the Google Apps Script project. You only need to do this once.\n     2. Compile the TypeScript files into a single JavaScript file and push it to Google Apps by running\n        `npm run deploy`. Run this every time you make changes.\n   - **Automatically**: You can configure GitHub Actions to automatically deploy your code every time you push\n     it (or every time you create a new release). This is advantageous because you can be sure your repository\n     will always have the same code that is deployed to Google Apps. However, Google's Clasp tool is not\n     designed to authenticate in CI environments and so this takes some more complicated setup and isn't\n     included in this template by default. One option for this might be\n     [`ericanastas/deploy-google-app-script-action`](https://github.com/ericanastas/deploy-google-app-script-action).\n\n## Available Scripts\n\nYou can run the following scripts by opening the project directory in your terminal (as long as you have Node\n\u0026 npm installed):\n\n- `npm install` Install all required dependencies.\n- `npm run build` Build your project to ensure it compiles properly.\n- `npm run format` Format your code automatically using Prettier.\n- `npm run lint` Check your code for common errors using ESLint.\n- `npm run login` Login to the Google Apps Script client so you can push/pull. You will need to run this once\n  on each device you use.\n- `npm run pull` Fetch the latest changes from Google Apps Script. You should only need to do this if you\n  change the project settings.\n- **`npm run push` Build your project and push it to Google Apps in one step.** The first time you run this,\n  you will be prompted to log in to your Google account. This command will automatically update any test\n  deployments.\n- `npm run deploy` Build and push your code, then create a new versioned\n  [deployment](https://developers.google.com/apps-script/concepts/deployments).\n\nYou can also run any [Clasp command](https://developers.google.com/apps-script/guides/clasp) with\n`npx clasp \u003ccommand\u003e`.\n\n## Automated GitHub Workflow\n\nThe template comes with a built-in configuration file for\n[GitHub Workflows](https://help.github.com/en/actions/configuring-and-managing-workflows). The workflow is\nconfigured to run on every push to the `main` branch as well as on every Pull Request as a Check, and it\nsimply checks the code to ensure that it passes linting and is buildable (has no type/syntax errors). This is\nknown as _continuous integration_ and provides a form of automated testing to ensure that your project's code\nis always valid.\n\nFor larger projects where more than one developer will be collaborating, it is reccomended to protect the\n`main` branch and only allow changes to it through Pull Requests in which all checks pass. You can learn more\nabout this from GitHub's\n[help articles](https://help.github.com/en/github/administering-a-repository/about-protected-branches).\n\nIf you would like to disable the workflow, simply delete the [`checks.yml`](./.github/workflows/checks.yml)\nfile.\n\n## Development Notes\n\nThe following notes have important information for writing code for Google Apps Script using this template.\nPlease read through them before you start.\n\n### **_Important_**: Exposing Functions to Google Apps Script\n\nIn order for your Google Apps to run any of your code, you'll need to expose one or more functions to the\nengine. In the traditional Google Apps Script environment, you'd do this by declaring global functions,\nhowever in this setup there is no concept of 'global' as all files are modules.\n\nInstead, only functions exported from `index.ts` will be available to Google Apps Script. Any function\nexported from `index.ts` will be accessible by all\n[triggers](https://developers.google.com/apps-script/guides/triggers) and anywhere else Google Apps might need\nto call your function, such as from a [custom menu](https://developers.google.com/apps-script/guides/menus).\n\nDue to [a bug](https://github.com/iansan5653/gas-ts-template/issues/2) in the Webpack plugin, only exports in\n`export {...}` form are supported:\n\n```ts\n// ❌ Does NOT work\nexport function bad1() {\n  /* ... */\n}\n\nexport const bad2 = () =\u003e {\n  /* ... */\n};\n\n// ✅ Does work:\nexport { good1 } from \"./good1.ts\";\n\nfunction good2() {\n  /* ... */\n}\nconst good3 = () =\u003e {\n  /* ... */\n};\n\nexport { good2, good3 };\n```\n\nExamples for all the simple triggers are given in [`index.ts`](./src/index.ts).\n\nFor cleaner, more usable code, it may be useful to reference functions by their `name` property instead of\nhardcoding the name into code. For example:\n\n```ts\nconst createButton = CardService.newTextButton().setText(\"Create\").setOnClickAction(\n  // Here we use `onClickCreateEvent.name` instead of hardcoding `\"onClickCreateEvent\"`\n  CardService.newAction().setFunctionName(onClickCreateEvent.name),\n);\n```\n\n### Circular Dependencies\n\nCircular dependencies (files that depend on each other in a circular manner) can cause unexpected issues like\n\"X is not a function\" or \"X is not defined\". If you are seeing these errors in your project and you know they\nare wrong, try checking for circular dependencies using [`madge`](https://github.com/pahen/madge) (not\nincluded in this template):\n\n1. Install `madge` globally with `npm i --global madge`.\n2. Check for circular dependencies with `madge src/index.ts --circular`.\n\n## Included Files\n\n- `.github`\n  - `workflows` All GitHub workflows are configured using YAML files in this directory.\n    - `checks.yml` This is where the continuous integration workflow is configured.\n- `src` This is where you'll put all your TypeScript files.\n  - `example.ts` Gives an example of how to export something from a local file.\n  - `index.ts` Provides you with the five basic triggers prebuilt, as well as an example of how to import from\n    a local file.\n- `.clasp.json` Provides the configuration for Clasp, the command-line tool which pushes code to Google Apps\n  Script.\n- `.claspignore` Tells Clasp to ignore every file except for `Code.js`, `appsscript.json`, and\n  `readme_appsscript.md`.\n- `.gitignore` Tells Git to ignore output files and `node_modules`.\n- `.prettierrc` Configures Prettier, the code formatter.\n- `appsscript.json` Controls the project setup and Apps Script environment. You can change the exception\n  logger, but don't change the runtime version.\n- `package.json` Lists the project dependencies and scripts.\n- `readme_appsscript.md` If anyone opens your project in the Apps Script editor, they'll just see a jumbled\n  file. This note helps them realize that the project should be edited outside of that environment.\n- `readme.md` This file.\n- `tsconfig.json` Configures the TypeScript compiler to enable strict mode and compile to CommonJS modules\n  from the `src` folder to the `build` folder.\n- `webpack.config.js` Configures Webpack to take files from the `build` folder and dependencies and merge them\n  all into a single `Code.js` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiansan5653%2Fgas-ts-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiansan5653%2Fgas-ts-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiansan5653%2Fgas-ts-template/lists"}