@bigbinary/babel-preset-neeto 1.0.9 → 1.0.11
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.
- package/.neetoci/bump_version.yml +14 -0
- package/.scripts/bump_version.sh +78 -0
- package/docs/zustand-pick.md +9 -11
- package/package.json +2 -2
- package/src/plugins/zustand-pick/index.js +9 -8
- package/src/tests/zustand-pick/transformations/array-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/default-value/output.js +3 -4
- package/src/tests/zustand-pick/transformations/dynamic-declare/output.js +5 -7
- package/src/tests/zustand-pick/transformations/dynamic-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/empty-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/no-duplicate-import/input.js +1 -1
- package/src/tests/zustand-pick/transformations/no-duplicate-import/output.js +3 -4
- package/src/tests/zustand-pick/transformations/string-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/use-store-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/with-other-imports/output.js +3 -4
- package/.github/CODEOWNERS +0 -1
- package/.github/workflows/create_and_publish_releases.yml +0 -77
- package/.github/workflows/publish.yml +0 -26
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
install_gh() {
|
|
4
|
+
type -p curl >/dev/null || sudo apt install curl -y
|
|
5
|
+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
6
|
+
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
7
|
+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null
|
|
8
|
+
sudo apt update
|
|
9
|
+
sudo apt install gh -y
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
handle_error() {
|
|
13
|
+
if [ $? -ne 0 ]; then
|
|
14
|
+
echo "Error: $1 failed. Please check the logs and resolve the issue before retrying."
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
bump_package() {
|
|
20
|
+
echo "== Bump the NPM package version =="
|
|
21
|
+
yarn install
|
|
22
|
+
handle_error "yarn install"
|
|
23
|
+
yarn config set version-tag-prefix "v"
|
|
24
|
+
yarn version --"$VERSION_LABEL" --no-git-tag-version
|
|
25
|
+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >~/.npmrc
|
|
26
|
+
yarn publish --non-interactive
|
|
27
|
+
handle_error "yarn publish"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
raise_pr() {
|
|
31
|
+
git config user.name "Joseph Mathew"
|
|
32
|
+
git config user.email "joseph.mathew@bigbinary.com"
|
|
33
|
+
git config core.hooksPath /dev/null
|
|
34
|
+
git push origin --delete bump-version
|
|
35
|
+
git checkout -b bump-version
|
|
36
|
+
git add -A
|
|
37
|
+
git commit -m "Bump version"
|
|
38
|
+
git push --set-upstream origin bump-version
|
|
39
|
+
gh pr create -B main -H bump-version -t "Bump version" -b "This is an automated PR." -l instant-mergepr -a @me
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
install_gh
|
|
43
|
+
|
|
44
|
+
LATEST_COMMIT_SHA=$(git log -1 --pretty=format:"%H")
|
|
45
|
+
echo "Latest commit SHA: $LATEST_COMMIT_SHA"
|
|
46
|
+
|
|
47
|
+
PR_NUMBER=$(gh pr list --state merged --search "$LATEST_COMMIT_SHA" --json number --jq ".[0].number")
|
|
48
|
+
echo "Last merged PR number: $PR_NUMBER"
|
|
49
|
+
|
|
50
|
+
PR_LABELS=$(gh pr view $PR_NUMBER --json labels --jq ".labels[].name" | tr "\n" " " | cut -d " " -f 1-)
|
|
51
|
+
echo "PR labels: $PR_LABELS"
|
|
52
|
+
|
|
53
|
+
[[ -z "$PR_LABELS" ]] && exit 0
|
|
54
|
+
|
|
55
|
+
ALL_VERSION_LABELS=(major minor patch)
|
|
56
|
+
|
|
57
|
+
PR_VERSION_LABELS=()
|
|
58
|
+
for version_label in "${ALL_VERSION_LABELS[@]}"; do
|
|
59
|
+
if echo "$PR_LABELS" | grep -q -o "$version_label"; then
|
|
60
|
+
PR_VERSION_LABELS+=("$version_label")
|
|
61
|
+
fi
|
|
62
|
+
done
|
|
63
|
+
|
|
64
|
+
PR_VERSION_LABELS_STR="${PR_VERSION_LABELS[*]}"
|
|
65
|
+
echo "Semantic versions present in PR labels: $PR_VERSION_LABELS_STR"
|
|
66
|
+
|
|
67
|
+
VERSION_LABEL=$(echo "${PR_VERSION_LABELS[0]}" | xargs)
|
|
68
|
+
echo "Version label selected: $VERSION_LABEL"
|
|
69
|
+
|
|
70
|
+
[[ -z "$VERSION_LABEL" ]] && exit 0
|
|
71
|
+
|
|
72
|
+
if [[ -n "$VERSION_LABEL" ]]; then
|
|
73
|
+
bump_package
|
|
74
|
+
else
|
|
75
|
+
echo "PR label doesn't exist"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
raise_pr
|
package/docs/zustand-pick.md
CHANGED
|
@@ -6,14 +6,13 @@ When we wanted to pick some properties from a zustand store, this is what we
|
|
|
6
6
|
need to do:
|
|
7
7
|
|
|
8
8
|
```js
|
|
9
|
-
import {
|
|
9
|
+
import { useShallow } from "zustand/shallow";
|
|
10
10
|
|
|
11
11
|
const { order, customer } = useGlobalStore(
|
|
12
|
-
store => ({
|
|
12
|
+
useShallow(store => ({
|
|
13
13
|
order: store[sessionId]?.globals.order,
|
|
14
14
|
customer: store[sessionId]?.globals.customer,
|
|
15
|
-
})
|
|
16
|
-
shallow
|
|
15
|
+
}))
|
|
17
16
|
);
|
|
18
17
|
```
|
|
19
18
|
|
|
@@ -30,14 +29,14 @@ const { order, customer } = useGlobalStore.pick([sessionId, "globals"]);
|
|
|
30
29
|
```
|
|
31
30
|
|
|
32
31
|
You might also notice that we don't have the
|
|
33
|
-
`import {
|
|
34
|
-
don't need that. The plugin will automatically add it for us at the time of
|
|
32
|
+
`import { useShallow } from "zustand/shallow"` statement in this piece of code.
|
|
33
|
+
We don't need that. The plugin will automatically add it for us at the time of
|
|
35
34
|
transpiling.
|
|
36
35
|
|
|
37
36
|
The plugin detects that `order` and `customer` properties are to be fetched from
|
|
38
37
|
the `store[sessionId].globals` property from `useGlobalStore` and it generates
|
|
39
38
|
code for it. Note that the plugin will automatically add
|
|
40
|
-
`import {
|
|
39
|
+
`import { useShallow } from "zustand/shallow"` for us. We don't need to add it
|
|
41
40
|
ourselves.
|
|
42
41
|
|
|
43
42
|
## Allowed syntaxes
|
|
@@ -170,13 +169,12 @@ const { order, customer } = useGlobalStore.pick([sessionId, "globals"]);
|
|
|
170
169
|
Will be transformed to:
|
|
171
170
|
|
|
172
171
|
```js
|
|
173
|
-
import {
|
|
172
|
+
import { useShallow } from "zustand/shallow";
|
|
174
173
|
const { order, customer } = useGlobalStore(
|
|
175
|
-
store => ({
|
|
174
|
+
useShallow(store => ({
|
|
176
175
|
order: store[sessionId]?.["globals"]?.["order"],
|
|
177
176
|
customer: store[sessionId]?.["globals"]?.["customer"],
|
|
178
|
-
})
|
|
179
|
-
shallow
|
|
177
|
+
}))
|
|
180
178
|
);
|
|
181
179
|
```
|
|
182
180
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/babel-preset-neeto",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "A babel preset to transform short code to boilerplate at compile time",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"eslint-plugin-unused-imports": "2.0.0",
|
|
62
62
|
"husky": "^8.0.0",
|
|
63
63
|
"jest": "^29.5.0",
|
|
64
|
-
"lint-staged": "
|
|
64
|
+
"lint-staged": "13.3.0",
|
|
65
65
|
"prettier": "^2.8.7"
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -62,13 +62,14 @@ module.exports = function ({ types }) {
|
|
|
62
62
|
declarator.init = types.callExpression(
|
|
63
63
|
types.identifier(declarator.init.callee.object.name),
|
|
64
64
|
[
|
|
65
|
-
types.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
types.callExpression(types.identifier("useShallow"), [
|
|
66
|
+
types.arrowFunctionExpression(
|
|
67
|
+
[types.identifier("store")],
|
|
68
|
+
types.objectExpression(
|
|
69
|
+
declarator.id.properties.map(toObjectProperty)
|
|
70
|
+
)
|
|
71
|
+
),
|
|
72
|
+
]),
|
|
72
73
|
]
|
|
73
74
|
);
|
|
74
75
|
|
|
@@ -76,7 +77,7 @@ module.exports = function ({ types }) {
|
|
|
76
77
|
path: astPath,
|
|
77
78
|
types,
|
|
78
79
|
source: "zustand/shallow",
|
|
79
|
-
importName: "
|
|
80
|
+
importName: "useShallow",
|
|
80
81
|
});
|
|
81
82
|
},
|
|
82
83
|
CallExpression(astPath) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { order, customer } = useGlobalStore(
|
|
3
|
-
store => ({
|
|
3
|
+
useShallow(store => ({
|
|
4
4
|
order: store["state"]?.[sessionId]?.["current"]?.[data]?.["order"],
|
|
5
5
|
customer: store["state"]?.[sessionId]?.["current"]?.[data]?.["customer"],
|
|
6
|
-
})
|
|
7
|
-
shallow
|
|
6
|
+
}))
|
|
8
7
|
);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { orderId = "#1001", customer = {} } = useGlobalStore(
|
|
3
|
-
store => ({
|
|
3
|
+
useShallow(store => ({
|
|
4
4
|
orderId: store["orderId"],
|
|
5
5
|
customer: store["customer"],
|
|
6
|
-
})
|
|
7
|
-
shallow
|
|
6
|
+
}))
|
|
8
7
|
);
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { [`customer ${id}`]: customer } = useGlobalStore(
|
|
3
|
-
store => ({
|
|
3
|
+
useShallow(store => ({
|
|
4
4
|
[`customer ${id}`]: store[sessionId]?.[`customer ${id}`],
|
|
5
|
-
})
|
|
6
|
-
shallow
|
|
5
|
+
}))
|
|
7
6
|
);
|
|
8
7
|
const { [orderId]: order } = useGlobalStore(
|
|
9
|
-
store => ({
|
|
8
|
+
useShallow(store => ({
|
|
10
9
|
[orderId]: store[sessionId]?.["orders"]?.[orderId],
|
|
11
|
-
})
|
|
12
|
-
shallow
|
|
10
|
+
}))
|
|
13
11
|
);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { order, customer } = useGlobalStore.pick();
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { order, customer, address } = useGlobalStore(
|
|
3
|
-
store => ({
|
|
3
|
+
useShallow(store => ({
|
|
4
4
|
order: store["state"]?.["order"],
|
|
5
5
|
customer: store["state"]?.["customer"],
|
|
6
6
|
address: store["state"]?.["address"],
|
|
7
|
-
})
|
|
8
|
-
shallow
|
|
7
|
+
}))
|
|
9
8
|
);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { sample } from "somewhere";
|
|
4
4
|
const { order, customer } = useGlobalStore(
|
|
5
|
-
store => ({
|
|
5
|
+
useShallow(store => ({
|
|
6
6
|
order: store["order"],
|
|
7
7
|
customer: store["customer"],
|
|
8
|
-
})
|
|
9
|
-
shallow
|
|
8
|
+
}))
|
|
10
9
|
);
|
package/.github/CODEOWNERS
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* @Amaljith-K
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
name: "Create and publish releases"
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
types: [closed]
|
|
7
|
-
jobs:
|
|
8
|
-
release:
|
|
9
|
-
name: "Create Release"
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
if: >-
|
|
12
|
-
${{ github.event.pull_request.merged == true && (
|
|
13
|
-
contains(github.event.pull_request.labels.*.name, 'patch') ||
|
|
14
|
-
contains(github.event.pull_request.labels.*.name, 'minor') ||
|
|
15
|
-
contains(github.event.pull_request.labels.*.name, 'major') ) }}
|
|
16
|
-
steps:
|
|
17
|
-
- name: Checkout the repository
|
|
18
|
-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
|
|
19
|
-
|
|
20
|
-
- name: Setup git user
|
|
21
|
-
run: |
|
|
22
|
-
git config user.name "Joseph Mathew"
|
|
23
|
-
git config user.email "joseph.mathew@bigbinary.com"
|
|
24
|
-
- name: Setup NodeJS LTS version
|
|
25
|
-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
|
|
26
|
-
with:
|
|
27
|
-
node-version-file: ".nvmrc"
|
|
28
|
-
|
|
29
|
-
- name: Setup the project
|
|
30
|
-
run: yarn install
|
|
31
|
-
|
|
32
|
-
- name: Prefix version tag with "v"
|
|
33
|
-
run: yarn config set version-tag-prefix "v"
|
|
34
|
-
|
|
35
|
-
- name: Disable Git commit hooks
|
|
36
|
-
run: git config core.hooksPath /dev/null
|
|
37
|
-
|
|
38
|
-
- name: Bump the patch version and create git tag on release
|
|
39
|
-
if: ${{ contains(github.event.pull_request.labels.*.name, 'patch') }}
|
|
40
|
-
run: yarn version --patch
|
|
41
|
-
|
|
42
|
-
- name: Bump the minor version and create git tag on release
|
|
43
|
-
if: ${{ contains(github.event.pull_request.labels.*.name, 'minor') }}
|
|
44
|
-
run: yarn version --minor
|
|
45
|
-
|
|
46
|
-
- name: Bump the major version and create git tag on release
|
|
47
|
-
if: ${{ contains(github.event.pull_request.labels.*.name, 'major') }}
|
|
48
|
-
run: yarn version --major
|
|
49
|
-
|
|
50
|
-
- name: Get the package version from package.json
|
|
51
|
-
uses: tyankatsu0105/read-package-version-actions@5aad2bb630a577ee4255546eb3ee0593df68f6ca
|
|
52
|
-
id: package-version
|
|
53
|
-
|
|
54
|
-
- name: Create a new version release commit
|
|
55
|
-
uses: EndBug/add-and-commit@050a66787244b10a4874a2a5f682130263edc192
|
|
56
|
-
with:
|
|
57
|
-
message: "New version release"
|
|
58
|
-
|
|
59
|
-
- name: Push the commit to main
|
|
60
|
-
uses: ad-m/github-push-action@492de9080c3179a3187bd456763f988f9a06e196
|
|
61
|
-
with:
|
|
62
|
-
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
63
|
-
branch: main
|
|
64
|
-
|
|
65
|
-
- name: Create a release draft on release
|
|
66
|
-
uses: release-drafter/release-drafter@ac463ffd9cc4c6ad5682af93dc3e3591c4657ee3
|
|
67
|
-
env:
|
|
68
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
69
|
-
with:
|
|
70
|
-
tag: v${{ steps.package-version.outputs.version }}
|
|
71
|
-
publish: true
|
|
72
|
-
|
|
73
|
-
- name: Publish the package on NPM
|
|
74
|
-
uses: JS-DevTools/npm-publish@22595ff8c4d0d9f53cef0656fbb90fbe06ee885c
|
|
75
|
-
with:
|
|
76
|
-
access: "public"
|
|
77
|
-
token: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Publish to npm
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [created]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
publish:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- name: Checkout the repository
|
|
12
|
-
uses: actions/checkout@v3
|
|
13
|
-
|
|
14
|
-
- name: Setup NodeJS LTS version
|
|
15
|
-
uses: actions/setup-node@v3
|
|
16
|
-
with:
|
|
17
|
-
node-version: "22.13"
|
|
18
|
-
|
|
19
|
-
- name: Setup the project
|
|
20
|
-
run: yarn install
|
|
21
|
-
|
|
22
|
-
- name: Publish the package on NPM
|
|
23
|
-
uses: JS-DevTools/npm-publish@v1
|
|
24
|
-
with:
|
|
25
|
-
access: "public"
|
|
26
|
-
token: ${{ secrets.NPM_TOKEN }}
|