babel-plugin-transform-react-templates 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ name: Add to main project
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - opened
7
+ pull_request:
8
+ types:
9
+ - opened
10
+
11
+ jobs:
12
+ add-to-project:
13
+ name: Add to main project
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/add-to-project@v0.1.0
17
+ with:
18
+ project-url: https://github.com/orgs/cgkineo/projects/3/views/1
19
+ github-token: ${{ secrets.ADDTOPROJECT_TOKEN }}
@@ -0,0 +1,30 @@
1
+ name: Release
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ jobs:
7
+ release:
8
+ name: Release
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: write # to be able to publish a GitHub release
12
+ issues: write # to be able to comment on released issues
13
+ pull-requests: write # to be able to comment on released pull requests
14
+ id-token: write # to enable use of OIDC for trusted publishing and npm provenance
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: 'lts/*'
24
+ registry-url: https://registry.npmjs.org
25
+ - name: Install dependencies
26
+ run: npm ci
27
+ - name: Release
28
+ env:
29
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30
+ run: npx semantic-release
package/README.md CHANGED
@@ -19,17 +19,37 @@ yarn add babel-plugin-transform-react-templates --dev
19
19
  ## Usage
20
20
 
21
21
  Code:
22
- ```js
23
- // src/reactTemplateRegister.js
24
22
 
25
- export default register(template, component) {
23
+ ```js
24
+ // src/reactTemplateHelpers.js
25
+ export default function register(template, component) {
26
26
  templates[template] = component;
27
27
  }
28
28
 
29
29
  export const templates = {};
30
+ ```
30
31
 
32
+ ```js
33
+ // src/templates/test.jsx
34
+ export default (data) => {
35
+ return <div className="test">
36
+ {data.testText}
37
+ </div>
38
+ }
31
39
  ```
40
+
41
+ ```js
42
+ // src/main.js
43
+ import { templates } from 'src/reactTemplateHelpers';
44
+
45
+ ReactDOM.render(templates['test']({
46
+ testText: 'testing text'
47
+ }), '#app');
48
+
49
+ ```
50
+
32
51
  With options:
52
+
33
53
  ```js
34
54
  plugins: [
35
55
  [
@@ -39,7 +59,7 @@ plugins: [
39
59
  // Any jsx file nested inside a templates folder
40
60
  '**/templates/**/*.jsx'
41
61
  ],
42
- importRegisterFunctionFromModule: 'src/reactTemplateRegister.js',
62
+ importRegisterFunctionFromModule: 'src/reactTemplateHelpers.js',
43
63
  registerFunctionName: 'register',
44
64
  registerTemplateName: (moduleId) => {
45
65
  // Use filename as template name
@@ -49,3 +69,6 @@ plugins: [
49
69
  ]
50
70
  ]
51
71
  ```
72
+
73
+ Notes:
74
+ You must inject the template paths if you want them to appear automatically or include them in a normal import.
package/package.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-react-templates",
3
- "version": "0.1.0",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "https://github.com/cgkineo/babel-plugin-transform-react-templates"
6
+ },
7
+ "version": "1.0.0",
4
8
  "description": "Babel plugin to register react templates with a global function",
5
9
  "license": "MIT",
6
10
  "main": "src/index.js",
@@ -16,6 +20,59 @@
16
20
  },
17
21
  "devDependencies": {
18
22
  "@babel/core": "^7.10.4",
19
- "@babel/helper-plugin-test-runner": "^7.10.4"
23
+ "@babel/helper-plugin-test-runner": "^7.10.4",
24
+ "@semantic-release/git": "^10.0.1",
25
+ "conventional-changelog-eslint": "^6.0.0",
26
+ "semantic-release": "^25.0.2",
27
+ "semantic-release-replace-plugin": "^1.2.7"
28
+ },
29
+ "release": {
30
+ "plugins": [
31
+ [
32
+ "@semantic-release/commit-analyzer",
33
+ {
34
+ "preset": "eslint"
35
+ }
36
+ ],
37
+ [
38
+ "@semantic-release/release-notes-generator",
39
+ {
40
+ "preset": "eslint"
41
+ }
42
+ ],
43
+ [
44
+ "semantic-release-replace-plugin",
45
+ {
46
+ "replacements": [
47
+ {
48
+ "files": "migrations/*.js",
49
+ "from": "@@CURRENT_VERSION",
50
+ "to": "${lastRelease.version}",
51
+ "countMatches": true,
52
+ "allowEmptyPaths": true
53
+ },
54
+ {
55
+ "files": "migrations/*.js",
56
+ "from": "@@RELEASE_VERSION",
57
+ "to": "${nextRelease.version}",
58
+ "countMatches": true,
59
+ "allowEmptyPaths": true
60
+ }
61
+ ]
62
+ }
63
+ ],
64
+ "@semantic-release/npm",
65
+ "@semantic-release/github",
66
+ [
67
+ "@semantic-release/git",
68
+ {
69
+ "assets": [
70
+ "package.json",
71
+ "migrations/*.js"
72
+ ],
73
+ "message": "Chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
74
+ }
75
+ ]
76
+ ]
20
77
  }
21
78
  }