Skip to content

Commit b0bcc8d

Browse files
authored
Merge pull request #1 from tolerious/feat/new-version
new version.
2 parents b6d4274 + a0a12bf commit b0bcc8d

14 files changed

Lines changed: 57 additions & 5834 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,33 @@ name: Node.js Package
55

66
on:
77
release:
8-
types: [ created ]
8+
types: [created]
99

1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
15+
- uses: pnpm/action-setup@v4
1516
- uses: actions/setup-node@v4
1617
with:
1718
node-version: 20
18-
- run: npm ci
19-
#- run: npm test
19+
cache: pnpm
20+
- run: pnpm install --frozen-lockfile
21+
#- run: pnpm test
2022

2123
publish-npm:
2224
needs: build
2325
runs-on: ubuntu-latest
2426
steps:
2527
- uses: actions/checkout@v4
28+
- uses: pnpm/action-setup@v4
2629
- uses: actions/setup-node@v4
2730
with:
2831
node-version: 20
2932
registry-url: https://registry.npmjs.org/
30-
- run: npm ci
31-
- run: npm publish
33+
cache: pnpm
34+
- run: pnpm install --frozen-lockfile
35+
- run: pnpm publish --no-git-checks
3236
env:
3337
NODE_AUTH_TOKEN: ${{secrets.NPM_ACCESS_TOKEN}}

.travis.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.yo-rc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"generator-generator": {
33
"structure": "nested"
44
}
5-
}
5+
}

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# generator-babel-plugin [![Node.js Package](https://github.com/tolerious/generator-babel-plugin/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/tolerious/generator-babel-plugin/actions/workflows/npm-publish.yml)
2+
23
使用Yeoman来创建babel plugin.
34
代码fork自[generator-babel-plugin](https://github.com/thejameskyle/generator-babel-plugin)
4-
原仓库经过测试,在本地无法运行了,故此fork了项目进行了修改。
5+
原仓库经过测试,在本地无法运行了,故此fork了项目进行了修改。
56

67
## 用法
78

@@ -10,13 +11,17 @@
1011
```shell
1112
$ npm i -g yo
1213
```
14+
1315
```shell
1416
$ npm i -g generator-babel-plugins
1517
```
18+
1619
**创建插件文件夹**
20+
1721
```shell
1822
mkdir my-babel-plugin && cd my-babel-plugin
1923
```
24+
2025
**运行generator**
2126

2227
```shell

__tests__/test-app.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ const helpers = require('yeoman-test');
77
describe('babel-plugin:app', () => {
88
describe('with prompt inputs', () => {
99
beforeAll((done) => {
10-
helpers.run(path.join(__dirname, '../generators/app'))
10+
helpers
11+
.run(path.join(__dirname, '../generators/app'))
1112
.withOptions({ skipInstall: true })
1213
.withPrompts({
1314
name: 'do-something-really-awesome',
1415
description: 'A plugin that does a really cool thing',
1516
githubUsername: 'my-username',
1617
authorName: 'Oswald ThatEndsWald',
1718
authorEmail: 'oswald@thatendswald.com',
18-
keywords: 'foo, bar'
19+
keywords: 'foo, bar',
1920
})
2021
.on('end', done);
2122
});
22-
23+
2324
it('creates files', () => {
2425
assert.file([
2526
'.gitignore',
@@ -29,25 +30,26 @@ describe('babel-plugin:app', () => {
2930
'package.json',
3031
'README.md',
3132
'src/index.js',
32-
'__tests__/index.js'
33+
'__tests__/index.js',
3334
]);
3435
});
35-
36+
3637
it('populates package.json correctly', () => {
3738
assert.jsonFileContent('package.json', {
3839
name: 'babel-plugin-do-something-really-awesome',
3940
version: '0.0.0',
4041
description: 'A plugin that does a really cool thing',
4142
repository: 'my-username/babel-plugin-do-something-really-awesome',
4243
author: 'Oswald ThatEndsWald <oswald@thatendswald.com>',
43-
keywords: ['foo', 'bar', 'babel-plugin']
44+
keywords: ['foo', 'bar', 'babel-plugin'],
4445
});
4546
});
4647
});
4748

4849
describe('without prompt inputs', () => {
4950
beforeAll((done) => {
50-
helpers.run(path.join(__dirname, '../generators/app'))
51+
helpers
52+
.run(path.join(__dirname, '../generators/app'))
5153
.withOptions({ skipInstall: true })
5254
.on('end', done);
5355
});
@@ -65,10 +67,11 @@ describe('babel-plugin:app', () => {
6567

6668
describe('with only author name', () => {
6769
beforeAll((done) => {
68-
helpers.run(path.join(__dirname, '../generators/app'))
70+
helpers
71+
.run(path.join(__dirname, '../generators/app'))
6972
.withOptions({ skipInstall: true })
7073
.withPrompts({
71-
authorName: 'Oswald ThatEndsWald'
74+
authorName: 'Oswald ThatEndsWald',
7275
})
7376
.on('end', done);
7477
});

__tests__/test-fixture.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const helpers = require('yeoman-test');
66

77
describe('BabelPlugin:generators/fixture', () => {
88
beforeAll((done) => {
9-
helpers.run(path.join(__dirname, '../generators/fixture'))
9+
helpers
10+
.run(path.join(__dirname, '../generators/fixture'))
1011
.withArguments('an-example')
1112
.withOptions({ skipInstall: true, force: true })
1213
.on('end', done);
@@ -15,7 +16,7 @@ describe('BabelPlugin:generators/fixture', () => {
1516
it('creates files', () => {
1617
assert.file([
1718
'__tests__/fixtures/an-example/actual.js',
18-
'__tests__/fixtures/an-example/expected.js'
19+
'__tests__/fixtures/an-example/expected.js',
1920
]);
2021
});
2122
});

generators/app/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export default class extends Generator {
153153
}
154154

155155
install() {
156-
// this.npmInstall();
156+
this.pnpmInstall();
157157
}
158158

159159
getAuthor() {

generators/app/templates/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
**Out**
1414

1515
```js
16-
"use strict";
16+
'use strict';
1717

1818
// output code
1919
```
@@ -45,7 +45,7 @@ $ babel --plugins <%= name %> script.js
4545
### Via Node API
4646

4747
```javascript
48-
require("@babel/core").transform("code", {
49-
plugins: ["<%= name %>"]
48+
require('@babel/core').transform('code', {
49+
plugins: ['<%= name %>'],
5050
});
5151
```

generators/app/templates/__tests__/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ describe('<%= description %>', () => {
77
fs.readdirSync(fixturesDir).map((caseName) => {
88
const fixtureDir = path.join(fixturesDir, caseName);
99
if (!fs.statSync(fixtureDir).isDirectory()) return;
10-
10+
1111
it(`should ${caseName.split('-').join(' ')}`, () => {
1212
const actualPath = path.join(fixtureDir, 'actual.js');
1313
const actual = transformFileSync(actualPath).code;
1414

15-
const expected = fs.readFileSync(
16-
path.join(fixtureDir, 'expected.js')
17-
).toString();
15+
const expected = fs
16+
.readFileSync(path.join(fixtureDir, 'expected.js'))
17+
.toString();
1818

1919
expect(actual.trim()).toEqual(expected.trim());
2020
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export default function({types: t }) {
1+
export default function ({ types: t }) {
22
return {
3-
visitor: {
4-
}
3+
visitor: {},
54
};
65
}

0 commit comments

Comments
 (0)