Skip to content
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

Upgrade repo #66

Merged
merged 11 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .changeset/changelog-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
const { config } = require("dotenv");
const { getInfo, getInfoFromPullRequest } = require("@changesets/get-github-info");

config();

module.exports = {
getDependencyReleaseLine: async (
) => {
return ""
},
getReleaseLine: async (changeset, type, options) => {
if (!options || !options.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
);
}

let prFromSummary;
let commitFromSummary;
let usersFromSummary = [];

const replacedChangelog = changeset.summary
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
let num = Number(pr);
if (!isNaN(num)) prFromSummary = num;
return "";
})
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
commitFromSummary = commit;
return "";
})
.replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
usersFromSummary.push(user);
return "";
})
.trim();

const [firstLine, ...futureLines] = replacedChangelog
.split("\n")
.map(l => l.trimRight());

const links = await (async () => {
if (prFromSummary !== undefined) {
let { links } = await getInfoFromPullRequest({
repo: options.repo,
pull: prFromSummary
});
if (commitFromSummary) {
links = {
...links,
commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`
};
}
return links;
}
const commitToFetchFrom = commitFromSummary || changeset.commit;
if (commitToFetchFrom) {
let { links } = await getInfo({
repo: options.repo,
commit: commitToFetchFrom
});
return links;
}
return {
commit: null,
pull: null,
user: null
};
})();

const users = usersFromSummary.length
? usersFromSummary
.map(
userFromSummary =>
`[@${userFromSummary}](https://github.com/${userFromSummary})`
)
.join(", ")
: links.user;

const pull = links.pull === null ? "" : ` ${links.pull}`
const commit = !!pull || links.commit === null ? "" : ` ${links.commit}`

const prefix = [
pull,
commit,
users === null ? "" : ` by ${users}`
].join("");

let lines = `${firstLine}\n${futureLines
.map(l => ` ${l}`)
.join("\n")}`;

if (firstLine[0] === '-') {
lines = `\n ${firstLine}\n${futureLines
.map(l => ` ${l}`)
.join("\n")}`;
}

return `\n\n-${prefix ? `${prefix} –` : ""} ${lines}`;
}
};
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "udecode/zustand-x" }],
"changelog": ["./changelog-github", { "repo": "udecode/zustand-x" }],
"commit": false,
"linked": [["zustand-x"]],
"access": "public",
Expand Down
6 changes: 6 additions & 0 deletions .changeset/early-dryers-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'zustand-x': major
---

- Rename `@udecode/zustood` package to `zustand-x`
- `createZustandStore`: new alias for `createStore`
84 changes: 84 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const {
getDefaultIgnorePatterns,
} = require('./config/eslint/helpers/getDefaultIgnorePatterns.cjs');

/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [
'turbo',

'./config/eslint/bases/javascript.cjs',
'./config/eslint/bases/typescript.cjs',
'./config/eslint/bases/regexp.cjs',
'./config/eslint/bases/jest.cjs',
'./config/eslint/bases/react.cjs',
'./config/eslint/bases/rtl.cjs',

'./config/eslint/bases/unicorn.cjs',

'./config/eslint/bases/prettier.cjs',
],
ignorePatterns: [
...getDefaultIgnorePatterns(),
'.next',
'.out',
'**/__registry__',
],
env: {
browser: true,
es6: true,
jest: true,
node: true,
webextensions: false,
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
node: {
moduleDirectory: ['node_modules'],
typescript: {
alwaysTryTypes: true,
},
},
typescript: {},
},
react: { version: 'detect' },
},
rules: {},
overrides: [
{
files: ['**/*.spec.*'],
extends: ['./config/eslint/bases/prettier.cjs'],
rules: {
'react/jsx-key': 'off',
'import/no-relative-packages': 'off',
'import/no-unresolved': 'off',
},
},
{
files: ['**/*.test.*', '**/*.spec.*', '**/*.fixture.*'],
env: {
jest: true,
},
rules: {
'@typescript-eslint/no-unused-vars': 'off',
// 'react-hooks/rules-of-hooks': 'off',
'no-restricted-imports': [
'error',
{
paths: [],
},
],
},
},
{
files: '**/*.mdx',
rules: {
'prettier/prettier': 'off',
},
},
],
};
18 changes: 0 additions & 18 deletions .eslintrc.js

This file was deleted.

15 changes: 0 additions & 15 deletions .github/CODEOWNERS

This file was deleted.

1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

11 changes: 10 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
**Description**


See changesets.

<!-- A clear and concise description of what this pull request solves. -->
<!-- If your change is non-trivial, please include a description of how the
new logic works, and why you decided to solve it the way you did. -->


<!-- **Example** -->



<!-- (optional) A sandbox, GIF or video showing the old and new behaviors after this
pullrequest is merged. Or a code sample showing the usage of a new API. -->

124 changes: 124 additions & 0 deletions .github/actions/yarn-nm-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
########################################################################################
# "yarn install" composite action for yarn 3/4+ and "nodeLinker: node-modules" #
#--------------------------------------------------------------------------------------#
# Requirement: @setup/node should be run before #
# #
# Usage in workflows steps: #
# #
# - name: 📥 Monorepo install #
# uses: ./.github/actions/yarn-nm-install #
# with: #
# enable-corepack: false # (default = 'false') #
# cache-npm-cache: false # (default = 'true') #
# cwd: ${{ github.workspace }}/apps/my-app # (default = '.') #
# cache-prefix: add cache key prefix # (default = 'default') #
# cache-node-modules: false # (default = 'false') #
# cache-install-state: false # (default = 'false') #
# #
# Reference: #
# - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a #
# #
# Versions: #
# - 1.1.0 - 22-07-2023 - Option to enable npm global cache folder. #
# - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. #
# - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) #
# - 1.0.2 - 02-06-2023 - install-state default to false #
# - 1.0.1 - 29-05-2023 - cache-prefix doc #
# - 1.0.0 - 27-05-2023 - new input: cache-prefix #
########################################################################################

name: 'Monorepo install (yarn)'
description: 'Run yarn install with node_modules linker and cache enabled'
inputs:
cwd:
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
required: false
default: '.'
cache-prefix:
description: 'Add a specific cache-prefix'
required: false
default: 'default'
cache-npm-cache:
description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)'
required: false
default: 'true'
cache-node-modules:
description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)'
required: false
default: 'false'
cache-install-state:
description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)'
required: false
default: 'false'
enable-corepack:
description: 'Enable corepack'
required: false
default: 'true'

runs:
using: 'composite'

steps:
- name: ⚙️ Enable Corepack
if: inputs.enable-corepack == 'true'
shell: bash
working-directory: ${{ inputs.cwd }}
run: corepack enable

- name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT"
id: yarn-config
shell: bash
working-directory: ${{ inputs.cwd }}
env:
YARN_ENABLE_GLOBAL_CACHE: 'false'
run: |
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT
echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT

- name: ♻️ Restore yarn cache
uses: actions/cache@v3
id: yarn-download-cache
with:
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
key: yarn-download-cache-${{ inputs.cache-prefix }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
restore-keys: |
yarn-download-cache-${{ inputs.cache-prefix }}-

- name: ♻️ Restore node_modules
if: inputs.cache-node-modules == 'true'
id: yarn-nm-cache
uses: actions/cache@v3
with:
path: ${{ inputs.cwd }}/**/node_modules
key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: ♻️ Restore global npm cache folder
if: inputs.cache-npm-cache == 'true'
id: npm-global-cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }}
key: npm-global-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: ♻️ Restore yarn install state
if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true'
id: yarn-install-state-cache
uses: actions/cache@v3
with:
path: ${{ inputs.cwd }}/.yarn/ci-cache
key: yarn-install-state-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: 📥 Install dependencies
shell: bash
working-directory: ${{ inputs.cwd }}
run: yarn install --immutable --inline-builds
env:
# Overrides/align yarnrc.yml options (v3, v4) for a CI context
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives
YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only)
YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size
YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install
Loading