-
-
Notifications
You must be signed in to change notification settings - Fork 13
Add TypeScript template #152
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
Merged
savetheclocktower
merged 8 commits into
pulsar-edit:master
from
savetheclocktower:add-typescript-template
Nov 23, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c9952e8
Add a new package template for TypeScript
savetheclocktower 44b38e3
Alter `ppm init` to allow generation of a TypeScript package…
savetheclocktower a88ad94
Add stub file explaining next steps after TypeScript generation
savetheclocktower 282b2c7
Tweak generated TS code to be friendlier on first run
savetheclocktower 42ce87e
Make the warning stay on screen
savetheclocktower 263e3a5
Merge branch 'master' of github.com:pulsar-edit/ppm into add-typescri…
savetheclocktower 86c2952
(And I did such a good job on the merge, too)
savetheclocktower 6e95461
Forgot that CoffeeScript is no longer the default!
savetheclocktower File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| .DS_Store | ||
| npm-debug.log | ||
| node_modules |
This file contains hidden or 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 @@ | ||
| ## 0.1.0 - First Release | ||
| * Every feature added | ||
| * Every bug fixed |
This file contains hidden or 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,20 @@ | ||
| Copyright (c) __current_year__ <Your name here> | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining | ||
| a copy of this software and associated documentation files (the | ||
| "Software"), to deal in the Software without restriction, including | ||
| without limitation the rights to use, copy, modify, merge, publish, | ||
| distribute, sublicense, and/or sell copies of the Software, and to | ||
| permit persons to whom the Software is furnished to do so, subject to | ||
| the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be | ||
| included in all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
| LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
| OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
| WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains hidden or 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,26 @@ | ||
| # __package-name__ package | ||
|
|
||
| A short description of your package. | ||
|
|
||
|  | ||
|
|
||
| ## Package authors | ||
|
|
||
| If you’ve just generated this package, here’s how to proceed: | ||
|
|
||
| 1. `npm install` will install the packages necessary for the build toolchain. | ||
| 2. `npm run watch` can be used during development; it will automatically recompile when files change. | ||
| 3. Specs run in JavaScript and should import the package (if necessary) from `../lib/index` rather than `../src/index`. | ||
| 4. `npm run build` can perform a build and should be run for safety’s sake before publishing. When you make changes, make sure you commit both the source files in `src` and the generated files in `lib`. | ||
|
|
||
| Other tasks to perform before publishing: | ||
|
|
||
| - [ ] Create a corresponding repository on GitHub and push your code to that location. | ||
| - [ ] Add specs in the `spec` folder and ensure they pass. | ||
| - [ ] Update the `LICENSE` and `CHANGELOG` files. | ||
| - [ ] Edit `package.json` to… | ||
| - [ ] …change the URL of the `repository` to match the GitHub repo you created. | ||
| - [ ] …add keywords. | ||
| - [ ] …write an accurate `description`. | ||
| - [ ] …change or remove the `activationCommands` field. | ||
| - [ ] Edit the `README` to add detail about your package — and to remove this instructional text! |
5 changes: 5 additions & 0 deletions
5
templates/package-typescript/keymaps/__package-name__.json.template
This file contains hidden or 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,5 @@ | ||
| { | ||
| "atom-workspace": { | ||
| "ctrl-alt-o": "__package-name__:toggle" | ||
| } | ||
| } |
This file contains hidden or 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,11 @@ | ||
| const description = `After installing your dependencies with \`npm install\`, you must run \`npm run build\` or \`npm run watch\` from the root in order to compile your TypeScript project into JavaScript — at which point you will no longer see this warning. | ||
|
|
||
| If you're stuck, follow the directions in your new package's \`README.md\`. | ||
| `; | ||
|
|
||
| exports.activate = () => { | ||
| atom.notifications.addWarning( | ||
| '__package-name__ is created but not built', | ||
| { description, dismissable: true } | ||
| ); | ||
| }; |
26 changes: 26 additions & 0 deletions
26
templates/package-typescript/menus/__package-name__.json.template
This file contains hidden or 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,26 @@ | ||
| { | ||
| "context-menu": { | ||
| "atom-text-editor": [ | ||
| { | ||
| "label": "Toggle __package-name__", | ||
| "command": "__package-name__:toggle" | ||
| } | ||
| ] | ||
| }, | ||
| "menu": [ | ||
| { | ||
| "label": "Packages", | ||
| "submenu": [ | ||
| { | ||
| "label": "__package-name__", | ||
| "submenu": [ | ||
| { | ||
| "label": "Toggle", | ||
| "command": "__package-name__:toggle" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,34 @@ | ||
| { | ||
| "name": "__package-name__", | ||
| "type": "module", | ||
| "source": "./src/index.ts", | ||
| "main": "./lib/index.cjs", | ||
| "version": "0.0.0", | ||
| "description": "A short description of your package", | ||
| "keywords": [ | ||
| ], | ||
| "activationCommands": { | ||
| "atom-workspace": "__package-name__:toggle" | ||
| }, | ||
| "repository": "https://github.com/__package-author__/__package-name__", | ||
| "license": "MIT", | ||
| "engines": { | ||
| "atom": ">=1.0.0 <2.0.0" | ||
| }, | ||
| "scripts": { | ||
| "build": "rollup -c rollup.config.js", | ||
| "watch": "rollup --watch -c rollup.config.js" | ||
| }, | ||
| "dependencies": { | ||
| }, | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^28.0.3", | ||
| "@rollup/plugin-json": "^6.1.0", | ||
| "@rollup/plugin-node-resolve": "^16.0.1", | ||
| "@rollup/plugin-typescript": "^12.1.2", | ||
| "rollup": "^4.40.0", | ||
| "tslib": "^2.8.1", | ||
| "typescript": "^5.8.3", | ||
| "@types/atom": "github:pulsar-edit/types" | ||
| } | ||
| } |
This file contains hidden or 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,87 @@ | ||
| import commonjs from '@rollup/plugin-commonjs'; | ||
| import resolve from '@rollup/plugin-node-resolve'; | ||
| import json from '@rollup/plugin-json'; | ||
| import typescript from '@rollup/plugin-typescript'; | ||
|
|
||
| // This is a preset Rollup configuration file designed for Pulsar community | ||
| // packages written in TypeScript. Here's what it gives us: | ||
| // | ||
| // * All dependencies that use CommonJS are preserved as-is. | ||
| // * All dependencies that use ES Modules are bundled and transpiled to | ||
| // CommonJS. (This is necessary because it is impossible for ESM files loaded | ||
| // in Electron's renderer process to have access to anything from a Node | ||
| // environment, whether built-in or NPM.) | ||
| // * JSON files can be imported directly with `import` syntax and do not need | ||
| // the "import attribute" clause. This corresponds to CommonJS's ability to | ||
| // `require('foo.json')`. | ||
| // | ||
| // Read https://www.electronjs.org/docs/latest/tutorial/esm#renderer-process | ||
| // for more information about the limitations of ESM in Electron's renderer | ||
| // process. | ||
| // | ||
| // Known caveats: | ||
| // | ||
| // * Not all ESM can be transpiled to CommonJS. If your module uses top-level | ||
| // `await` or does dynamic importing (via `await import`), Rollup might be | ||
| // unable to transpile it. If so, you'll have to find a workaround or use a | ||
| // different dependency. | ||
| // | ||
| // One possible workaround is reverting to an older version of the same | ||
| // dependency. Many popular packages that use newer ES features will have an | ||
| // older version that doesn't rely on those features, and perhaps an even | ||
| // older version that is written in CommonJS. | ||
| // | ||
| // * We have been unable to find a combination of plugins that makes it | ||
| // possible to use SolidJS (with JSX) in a TypeScript project while also | ||
| // satisfying the constraints above. (See | ||
| // https://docs.solidjs.com/configuration/typescript for more information.) | ||
| // We have managed to make this work for the equivalent toolchain in | ||
| // JavaScript, but the addition of TypeScript seems to complicate things | ||
| // further. Feel free to customize what's here and let us know if you find a | ||
| // configuration that works. | ||
| // | ||
| export default { | ||
| input: 'src/index.ts', | ||
| output: { | ||
| file: 'lib/index.cjs', | ||
| // Output CommonJS as required by Electron in renderer code. | ||
| format: 'cjs', | ||
| exports: 'auto', | ||
| interop: 'auto', | ||
| sourcemap: true | ||
| }, | ||
| plugins: [ | ||
| resolve({ | ||
| extensions: ['.js', '.ts', '.json'], | ||
| // Look in `node_modules` for dependencies. | ||
| preferBuiltins: true, | ||
| // Prefer the `main` field to the `module` field in `package.json`; this | ||
| // means that, when a package offers both CommonJS and ESM versions of | ||
| // itself, we'll prefer the CJS so that transpilation can be avoided. | ||
| mainFields: ['main', 'module'] | ||
| }), | ||
| commonjs({ | ||
| // Transpile everything, even things in `node_modules`. | ||
| include: /node_modules/, | ||
| // Enable transformations of ES modules in `node_modules`. | ||
| transformMixedEsModules: true, | ||
| // Handle requiring of JSON files. | ||
| ignoreDynamicRequires: false | ||
| }), | ||
| typescript({ | ||
| tsconfig: './tsconfig.json', | ||
| sourceMap: true | ||
| }), | ||
| // Allows requiring of JSON files directly. | ||
| json() | ||
| ], | ||
| // Mark certain packages as external; this tells Rollup not to try to | ||
| // transpile the code in these packages. You may opt into this for any | ||
| // dependency that exports a CommonJS version. | ||
| // | ||
| // `atom` _must_ be present in this list because imports from `atom` will be | ||
| // resolved at runtime. | ||
| external: [ | ||
| 'atom' | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.