{"id":22306084,"url":"https://github.com/teles/gas-custom","last_synced_at":"2025-03-26T00:47:56.791Z","repository":{"id":265581071,"uuid":"714622420","full_name":"teles/gas-custom","owner":"teles","description":"Google App Scripts Custom Applications","archived":false,"fork":false,"pushed_at":"2023-11-05T12:22:15.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T10:12:21.270Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/teles.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}},"created_at":"2023-11-05T12:22:13.000Z","updated_at":"2023-11-05T12:22:29.000Z","dependencies_parsed_at":"2024-11-30T01:46:16.807Z","dependency_job_id":"9f479ebc-ad3f-40cd-a6e4-40fbd21b1d6c","html_url":"https://github.com/teles/gas-custom","commit_stats":null,"previous_names":["teles/gas-custom"],"tags_count":0,"template":false,"template_full_name":"iansan5653/gas-ts-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teles%2Fgas-custom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teles%2Fgas-custom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teles%2Fgas-custom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teles%2Fgas-custom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teles","download_url":"https://codeload.github.com/teles/gas-custom/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245568585,"owners_count":20636803,"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","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":[],"created_at":"2024-12-03T19:14:09.783Z","updated_at":"2025-03-26T00:47:56.763Z","avatar_url":"https://github.com/teles.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Apps \u0026 TypeScript Project Template\n\n**Note: The GitHub Workflows build will always be failing for this template\nrepo as it doesn't have a package-lock.json file. This is intentional! When\nyou run `npm i` for your project, just make sure to commit the lockfile.**\n\nThis repository provides a simple template to start a new\n[Google Apps Script](https://developers.google.com/apps-script) project with\nTypeScript. Building, linting, formatting, and pushing to Google Apps are all\nbuilt in.\n\nThe project is set up with a TypeScript configuration that transforms your\nTypeScript files in the `src` directory into JavaScript files in the `build`\ndirectory. It's not enough to upload those files as-is to Google Apps, however,\nbecause Apps Script doesn't support installing and running dependencies, and\nuploaded files are run in random order - they aren't linked together at all. To\nsolve this problem, a second build step uses Webpack to combine all files and\ndepdendencies into a single minified `Code.js` file, which is the only file that\nis actually pushed to Google Apps.\n\n## Getting Started\n\n1. Install [Node.js](https://nodejs.org/en/).\n2. Click\n   [\"Use This Template\"](https://github.com/iansan5653/gas-ts-template/generate)\n   to start a new repository. Clone your new repo and open a terminal in the\n   local directory. This template includes some configuration for VSCode, but\n   you can use any editor.\n3. Install all of the dependencies by running `npm install`.\n4. Start a new Google Apps Script project by going to\n   https://script.google.com/home and clicking **New Project**. You can also\n   start a project tied directly to a specific Google Apps file by opening the\n   file and clicking **Tools** -\u003e **Script Editor**.\n5. Click **File** -\u003e **Project Properties** in the Google Apps Script editor.\n   Enter a project name if prompted to, then on the **Info** tab in the\n   **Project Properties** window, find and copy the **Script ID**.\n6. Replace `SCRIPT_ID` in [`.clasp.json`](./.clasp.json) with your project's ID.\n   This ID is _not_ a secret - you can safely commit it to your repository.\n7. Add your TypeScript code in the `src` folder. Note that unlike in a normal\n   Google Apps Script project, only what is imported into the `index.ts` file\n   will be compiled into the script, and all files must be in the `src` folder\n   (except external dependencies).\n8. Optional: lint your code with `npm run lint` and/or auto-format your code\n   with `npm run format`. Typically you will want to install the ESLint and/or\n   Prettier extensions in your preferred code editor.\n9. Log in to Google Apps Script by running `npm run login`. Make sure to use the\n   same account you used to make the Google Apps Script project.\n10. Compile the TypeScript files into a single JavaScript file and push it to\n    Google Apps by running `npm run push`. Run this every time you make changes.\n    If you ever change the project configuration (ie, by adding new APIs), you\n    will need to sync the `appsscript.json` file by running `npm run pull`\n    before you run `npm run push`.\n\n## Available Scripts\n\nYou can run the following scripts by opening the project directory in your\nterminal (as long as you have Node \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.\n  You will need to run this once on each device you use.\n- `npm run pull` Fetch the latest changes from Google Apps Script. You should\n  only need to do this if you change the project settings.\n- **`npm run push` Build your project and push it to Google Apps in one step.**\n  The first time you run this, you will be prompted to log in to your Google\n  account.\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).\nThe workflow is configured to run on every push to the `master` branch as well\nas on every Pull Request as a Check, and it simply checks the code to ensure\nthat 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\nensure that your project's code is always valid.\n\nFor larger projects where more than one developer will be collaborating, it is\nreccomended to protect the `master` branch and only allow changes to it through\nPull Requests in which all checks pass. You can learn more about this from\nGitHub'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\n[`checks.yml`](./.github/workflows/checks.yml) file.\n\n## Development Notes\n\nThe following notes have important information for writing code for Google Apps\nScript using this template. Please 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\nor more functions to the engine. In the traditional Google Apps Script\nenvironment, you'd do this by declaring global functions, however in this setup\nthere is no concept of 'global' as all files are modules.\n\nInstead, you need to add these to the `global` object. This object type is declared\nin `src/global.d.ts` so you can assign to it from any file, although as a matter\nof best-practice you may want to confine global assignments to your `index.ts`\nfile. Any function added to the `global` object will be available under that\nname to all\n[triggers](https://developers.google.com/apps-script/guides/triggers) and\nanywhere else Google Apps might need to call your function, such as from a\n[custom menu](https://developers.google.com/apps-script/guides/menus).\n\nNote that the field in `global` that you assign the function, not the function's\nname, is treated as the function name. For example, the following function will\nbe called by the `onOpen` trigger, _not_ the `onEdit` trigger:\n\n```ts\nfunction onEdit() {}\n\nglobal.onOpen = onEdit;\n```\n\nFurther documentation is provided with the `global` type definition in\n[`global.d.ts`](https://github.com/iansan5653/gas-ts-template/blob/master/src/global.d.ts)\nand examples for all the simple triggers are given in\n[`index.ts`](https://github.com/iansan5653/gas-ts-template/blob/master/src/index.ts#L39-L43).\n\n### Circular Dependencies\n\nCircular dependencies (files that depend on each other in a circular manner) can\ncause unexpected issues like \"X is not a function\" or \"X is not defined\". If you\nare seeing these errors in your project and you know they are wrong, try\nchecking for circular dependencies using\n[`madge`](https://github.com/pahen/madge) (not included 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\n    directory.\n    - `checks.yml` This is where the continuous integration workflow is\n      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\n    example of how to import from a local file.\n  - `global.d.ts` Provides type-definitions for the global object from which\n    triggers are exported.\n- `.clasp.json` Provides the configuration for Clasp, the command-line tool\n  which pushes code to Google Apps Script.\n- `.claspignore` Tells Clasp to ignore every file except for `Code.js`,\n  `appsscript.json`, and `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\n  can change the exception 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,\n  they'll just see a jumbled file. This note helps them realize that the project\n  should be edited outside of that environment.\n- `readme.md` This file.\n- `tsconfig.json` Configures the TypeScript compiler to enable strict mode and\n  compile to CommonJS modules from the `src` folder to the `build` folder.\n- `webpack.config.js` Configures Webpack to take files from the `build` folder\n  and dependencies and merge them all into a single `Code.js` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteles%2Fgas-custom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteles%2Fgas-custom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteles%2Fgas-custom/lists"}