-
-
Notifications
You must be signed in to change notification settings - Fork 15
Add “transpiled JavaScript” template #161
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bc3bc78
Add skeleton template files for transpiled-JS project
savetheclocktower 51da28b
Add `--transpiled` flag for opting into the transpiled-JS project type
savetheclocktower 6ca9620
Add spec for `--transpiled` flag
savetheclocktower ff65c94
Point both `@types/atom` references to the published types package…
savetheclocktower 4f711fa
Fix the specs
savetheclocktower 4770877
Change `init` syntax; make transpiled a flavor of `syntax`…
savetheclocktower 57115b2
Remove last traces of the `--transpiled` flag
savetheclocktower 8b65e59
Test on Node 20…
savetheclocktower 83fde13
Address feedback
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
5 changes: 3 additions & 2 deletions
5
templates/package-coffeescript/styles/__package-name__.less.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
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-javascript-transpiled/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 project — 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-javascript-transpiled/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,30 @@ | ||
| { | ||
| "name": "__package-name__", | ||
| "type": "module", | ||
| "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": "^4.40.0", | ||
| "@types/atom": "npm:@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,74 @@ | ||
| import commonjs from '@rollup/plugin-commonjs'; | ||
| import resolve from '@rollup/plugin-node-resolve'; | ||
| import json from '@rollup/plugin-json'; | ||
|
|
||
| // This is a preset Rollup configuration file designed for Pulsar community | ||
| // packages written in JavaScript. It is useful when you've got dependencies | ||
| // written in ESM that need to be transpiled to CJS. 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. | ||
| // | ||
| export default { | ||
| input: 'src/index.js', | ||
| 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', '.jsx', '.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 | ||
| }), | ||
| // 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' | ||
| ] | ||
| } |
74 changes: 74 additions & 0 deletions
74
templates/package-javascript-transpiled/spec/__package-name__-spec.js.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,74 @@ | ||
| 'use babel'; | ||
|
|
||
| import __PackageName__ from '../lib/index'; | ||
|
|
||
| // Use the command `window:run-package-specs` (cmd-alt-ctrl-p on macOS, | ||
| // ctrl-shift-y on Windows/Linux) to run specs. | ||
| // | ||
| // To run a specific `it` or `describe` block add an `f` to the front (e.g., | ||
| // `fit` or `fdescribe`). Remove the `f` to unfocus the block. | ||
|
|
||
| describe('__PackageName__', () => { | ||
| let workspaceElement, activationPromise; | ||
|
|
||
| beforeEach(() => { | ||
| workspaceElement = atom.views.getView(atom.workspace); | ||
| activationPromise = atom.packages.activatePackage('__package-name__'); | ||
| }); | ||
|
|
||
| describe('when the __package-name__:toggle event is triggered', () => { | ||
| it('hides and shows the modal panel', () => { | ||
| // Before the activation event the view is not on the DOM, and no panel | ||
| // has been created | ||
| expect(workspaceElement.querySelector('.__package-name__')).not.toExist(); | ||
|
|
||
| // This is an activation event, triggering it will cause the package to be | ||
| // activated. | ||
| atom.commands.dispatch(workspaceElement, '__package-name__:toggle'); | ||
|
|
||
| waitsForPromise(() => { | ||
| return activationPromise; | ||
| }); | ||
|
|
||
| runs(() => { | ||
| expect(workspaceElement.querySelector('.__package-name__')).toExist(); | ||
|
|
||
| let __packageName__Element = workspaceElement.querySelector('.__package-name__'); | ||
| expect(__packageName__Element).toExist(); | ||
|
|
||
| let __packageName__Panel = atom.workspace.panelForItem(__packageName__Element); | ||
| expect(__packageName__Panel.isVisible()).toBe(true); | ||
| atom.commands.dispatch(workspaceElement, '__package-name__:toggle'); | ||
| expect(__packageName__Panel.isVisible()).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| it('hides and shows the view', () => { | ||
| // This test shows you an integration test testing at the view level. | ||
|
|
||
| // Attaching the workspaceElement to the DOM is required to allow the | ||
| // `toBeVisible()` matchers to work. Anything testing visibility or focus | ||
| // requires that the workspaceElement is on the DOM. Tests that attach the | ||
| // workspaceElement to the DOM are generally slower than those off DOM. | ||
| jasmine.attachToDOM(workspaceElement); | ||
|
|
||
| expect(workspaceElement.querySelector('.__package-name__')).not.toExist(); | ||
|
|
||
| // This is an activation event, triggering it causes the package to be | ||
| // activated. | ||
| atom.commands.dispatch(workspaceElement, '__package-name__:toggle'); | ||
|
|
||
| waitsForPromise(() => { | ||
| return activationPromise; | ||
| }); | ||
|
|
||
| runs(() => { | ||
| // Now we can test for view visibility | ||
| let __packageName__Element = workspaceElement.querySelector('.__package-name__'); | ||
| expect(__packageName__Element).toBeVisible(); | ||
| atom.commands.dispatch(workspaceElement, '__package-name__:toggle'); | ||
| expect(__packageName__Element).not.toBeVisible(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
9 changes: 9 additions & 0 deletions
9
templates/package-javascript-transpiled/spec/__package-name__-view-spec.js.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,9 @@ | ||
| 'use babel'; | ||
|
|
||
| import __PackageName__View from '../lib/__package-name__-view'; | ||
|
|
||
| describe('__PackageName__View', () => { | ||
| it('has one valid test', () => { | ||
| expect('life').toBe('easy'); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.