svelte-tel-input 0.1.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.
- package/.changeset/config.json +9 -0
- package/.editorconfig +13 -0
- package/.eslintignore +11 -0
- package/.eslintrc.cjs +30 -0
- package/.github/workflows/lint.yml +12 -0
- package/.github/workflows/release.yml +50 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +10 -0
- package/.prettierrc.cjs +6 -0
- package/.storybook/main.cjs +38 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.cjs +39 -0
- package/CHANGELOG.md +23 -0
- package/README.md +19 -0
- package/babel.config.cjs +12 -0
- package/docker-compose.yml +18 -0
- package/docs/_index.md +1 -0
- package/jest.config.cjs +21 -0
- package/package.json +164 -0
- package/postcss.config.cjs +21 -0
- package/scripts/changelog-github-custom.cjs +110 -0
- package/scripts/changelog-github-custom.test.ts +136 -0
- package/scripts/changelog-github-custom.ts +127 -0
- package/src/app.css +4 -0
- package/src/app.html +13 -0
- package/src/global.d.ts +1 -0
- package/src/hooks.ts +9 -0
- package/src/lib/assets/countries.ts +605 -0
- package/src/lib/assets/regions.ts +46 -0
- package/src/lib/components/Input/SvelteTelInput.svelte +29 -0
- package/src/lib/components/LazyLoad/LazyLoad.svelte +23 -0
- package/src/lib/components/Select/CountrySelect.svelte +15 -0
- package/src/lib/components/Select/RegionSelect.svelte +15 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/models/enums/PhoneType.enum.ts +4 -0
- package/src/lib/models/enums/index.ts +1 -0
- package/src/lib/models/index.ts +1 -0
- package/src/lib/models/interfaces/Select.interface.ts +5 -0
- package/src/lib/models/types/DynamicSvelteComponent.type.ts +9 -0
- package/src/lib/models/types/Select.type.ts +3 -0
- package/src/lib/stores/index.ts +35 -0
- package/src/lib/utils/directives/clickOutsideAction.ts +13 -0
- package/src/lib/utils/simulator.ts +5 -0
- package/src/lib/utils/typeCheck.ts +17 -0
- package/src/routes/__layout.svelte +11 -0
- package/src/routes/index.svelte +22 -0
- package/static/favicon.ico +0 -0
- package/static/robots.txt +3 -0
- package/svelte.config.js +34 -0
- package/tailwind.config.cjs +10 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@1.6.3/schema.json",
|
|
3
|
+
"changelog": ["../scripts/changelog-github-custom.cjs", { "repo": "gyurielf/svelte-tel-input" }],
|
|
4
|
+
"commit": false,
|
|
5
|
+
"linked": [],
|
|
6
|
+
"access": "public",
|
|
7
|
+
"baseBranch": "main",
|
|
8
|
+
"updateInternalDependencies": "patch"
|
|
9
|
+
}
|
package/.editorconfig
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# EditorConfig is awesome:
|
|
2
|
+
# This file is for unifying the coding style for different editors and IDEs.
|
|
3
|
+
# More information at http://editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
[*]
|
|
8
|
+
charset = utf-8
|
|
9
|
+
indent_size = 4
|
|
10
|
+
indent_style = space
|
|
11
|
+
end_of_line = lf
|
|
12
|
+
insert_final_newline = true
|
|
13
|
+
trim_trailing_whitespace = true
|
package/.eslintignore
ADDED
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
|
7
|
+
'plugin:jest/recommended',
|
|
8
|
+
'prettier'
|
|
9
|
+
],
|
|
10
|
+
plugins: ['svelte3', '@typescript-eslint', 'jest'],
|
|
11
|
+
ignorePatterns: ['*.cjs', 'node_modules'],
|
|
12
|
+
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
|
|
13
|
+
settings: {
|
|
14
|
+
'svelte3/typescript': () => require('typescript'),
|
|
15
|
+
'svelte3/ignore-styles': () => true
|
|
16
|
+
},
|
|
17
|
+
parserOptions: {
|
|
18
|
+
sourceType: 'module',
|
|
19
|
+
ecmaVersion: 2020
|
|
20
|
+
},
|
|
21
|
+
env: {
|
|
22
|
+
browser: true,
|
|
23
|
+
es2020: true,
|
|
24
|
+
node: true
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'as' }],
|
|
28
|
+
'@typescript-eslint/array-type': ['error', { default: 'array' }]
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- 'main'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
name: Release
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout Repo
|
|
14
|
+
uses: actions/checkout@v2
|
|
15
|
+
with:
|
|
16
|
+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
|
|
19
|
+
- name: Setup Node.js 16.x
|
|
20
|
+
uses: actions/setup-node@v2
|
|
21
|
+
with:
|
|
22
|
+
node-version: 16.x
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: npm install --frozen-lockfile
|
|
26
|
+
|
|
27
|
+
- name: Packaging
|
|
28
|
+
run: |
|
|
29
|
+
npm run package
|
|
30
|
+
# ls -l package
|
|
31
|
+
# cd package
|
|
32
|
+
# npm publish
|
|
33
|
+
|
|
34
|
+
- name: Creating .npmrc
|
|
35
|
+
run: |
|
|
36
|
+
cat << EOF > "$HOME/.npmrc"
|
|
37
|
+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
|
|
38
|
+
EOF
|
|
39
|
+
env:
|
|
40
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
41
|
+
|
|
42
|
+
- name: Create Release Pull Request or Publish to npm
|
|
43
|
+
id: changesets
|
|
44
|
+
uses: changesets/action@v1
|
|
45
|
+
with:
|
|
46
|
+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
|
|
47
|
+
publish: npm run release
|
|
48
|
+
env:
|
|
49
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
50
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierignore
ADDED
package/.prettierrc.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const sveltePreprocess = require('svelte-preprocess');
|
|
2
|
+
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const autoprefixer = require('autoprefixer');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx|svelte)'],
|
|
8
|
+
addons: [
|
|
9
|
+
'@storybook/addon-links',
|
|
10
|
+
'@storybook/addon-essentials',
|
|
11
|
+
'@storybook/addon-svelte-csf',
|
|
12
|
+
'storybook-dark-mode',
|
|
13
|
+
'@storybook/addon-a11y'
|
|
14
|
+
],
|
|
15
|
+
svelteOptions: {
|
|
16
|
+
preprocess: [
|
|
17
|
+
sveltePreprocess({
|
|
18
|
+
postcss: {
|
|
19
|
+
plugins: [autoprefixer]
|
|
20
|
+
},
|
|
21
|
+
scss: {
|
|
22
|
+
// Should replaced to tailwind..
|
|
23
|
+
// prependData: `@import 'src/lib/styles/init/all.scss';`,
|
|
24
|
+
outputStyle: 'compressed'
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
webpackFinal: async (config) => {
|
|
30
|
+
config.resolve.plugins.push(
|
|
31
|
+
new TsconfigPathsPlugin({
|
|
32
|
+
configFile: path.resolve(__dirname, '../tsconfig.json')
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return config;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!--gitlab_visual_review-->
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { themes } from '@storybook/theming';
|
|
2
|
+
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
|
|
3
|
+
|
|
4
|
+
export const parameters = {
|
|
5
|
+
darkMode: {
|
|
6
|
+
// Override the default dark theme
|
|
7
|
+
dark: { ...themes.dark, appBg: 'black' },
|
|
8
|
+
// Override the default light theme
|
|
9
|
+
light: { ...themes.normal, appBg: 'white' },
|
|
10
|
+
classTarget: 'html',
|
|
11
|
+
stylePreview: true,
|
|
12
|
+
darkClass: 'dark',
|
|
13
|
+
lightClass: 'light'
|
|
14
|
+
},
|
|
15
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
16
|
+
controls: {
|
|
17
|
+
matchers: {
|
|
18
|
+
color: /(background|color)$/i,
|
|
19
|
+
date: /Date$/
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
backgrounds: {
|
|
23
|
+
default: '',
|
|
24
|
+
values: [
|
|
25
|
+
{
|
|
26
|
+
name: 'Light',
|
|
27
|
+
value: '#f5f6fa'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Dark',
|
|
31
|
+
value: '#1b2431'
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
target: 'html'
|
|
35
|
+
},
|
|
36
|
+
viewport: {
|
|
37
|
+
viewports: INITIAL_VIEWPORTS
|
|
38
|
+
}
|
|
39
|
+
};
|
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Svelte Tel Input
|
|
2
|
+
|
|
3
|
+
lets test 2
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ npm install --save libphonenumber-js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Svelte Tel Input is distributed via [npm](https://www.npmjs.com/package/svelte-tel-input).
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
$ yarn add svelte-tel-input
|
|
17
|
+
# or
|
|
18
|
+
$ npm install --save svelte-tel-input
|
|
19
|
+
```
|
package/babel.config.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
version: '3.9'
|
|
2
|
+
services:
|
|
3
|
+
node:
|
|
4
|
+
image: 'node:16.13.1'
|
|
5
|
+
container_name: ui-kit
|
|
6
|
+
working_dir: /home/node/app
|
|
7
|
+
command: 'sh -c "npm i && npm run prepare && npm run dev -- --host"'
|
|
8
|
+
user: node
|
|
9
|
+
tty: true
|
|
10
|
+
ports:
|
|
11
|
+
# Server
|
|
12
|
+
- '3000:3000'
|
|
13
|
+
# Vite
|
|
14
|
+
- '24678:24678'
|
|
15
|
+
# Storybook
|
|
16
|
+
- '6006:6006'
|
|
17
|
+
volumes:
|
|
18
|
+
- ./:/home/node/app
|
package/docs/_index.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# TODO
|
package/jest.config.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
verbose: true,
|
|
3
|
+
collectCoverage: true,
|
|
4
|
+
coverageDirectory: './coverage',
|
|
5
|
+
coverageReporters: ['cobertura', 'html', 'text', 'text-summary'],
|
|
6
|
+
transform: {
|
|
7
|
+
'^.+\\.svelte$': [
|
|
8
|
+
'svelte-jester',
|
|
9
|
+
{
|
|
10
|
+
preprocess: true
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
'^.+\\.ts$': 'ts-jest',
|
|
14
|
+
'^.+\\.js$': 'babel-jest'
|
|
15
|
+
},
|
|
16
|
+
moduleFileExtensions: ['js', 'ts', 'svelte'],
|
|
17
|
+
moduleNameMapper: {
|
|
18
|
+
'\\$lib/(.*)': '<rootDir>/src/lib/$1'
|
|
19
|
+
},
|
|
20
|
+
transformIgnorePatterns: ['node_modules/(?!(focus-svelte)/)']
|
|
21
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "svelte-tel-input",
|
|
3
|
+
"description": "svelte-tel-input",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/gyurielf/svelte-tel-input.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/gyurielf/svelte-tel-input#readme",
|
|
10
|
+
"engines": {
|
|
11
|
+
"npm": ">= 7",
|
|
12
|
+
"yarn": "please-use-npm",
|
|
13
|
+
"node": ">= 16"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "svelte-kit build",
|
|
17
|
+
"commitmsg": "commitlint -e $GIT_PARAMS",
|
|
18
|
+
"dev": "svelte-kit dev",
|
|
19
|
+
"eslint": "eslint --ext .js,.ts,.svelte .",
|
|
20
|
+
"eslint:fix": "eslint --fix",
|
|
21
|
+
"lint": "npm run prettier:check && npm run eslint && npm run ts && npm run svelte-check",
|
|
22
|
+
"lint:fix": "npm run eslint:fix && npm run prettier:fix",
|
|
23
|
+
"package": "svelte-kit package",
|
|
24
|
+
"prettier": "prettier",
|
|
25
|
+
"prettier:check": "prettier --check --plugin-search-dir=. .",
|
|
26
|
+
"prettier:fix": "prettier --write --plugin-search-dir=. .",
|
|
27
|
+
"prepare": "husky install",
|
|
28
|
+
"preview": "svelte-kit preview",
|
|
29
|
+
"release": "npm run package && npx changeset publish",
|
|
30
|
+
"svelte-check": "svelte-check --ignore 'dist,build,coverage,.storybook,.svelte-kit,package' --threshold warning --fail-on-warnings",
|
|
31
|
+
"storybook": "start-storybook -p 6006",
|
|
32
|
+
"build-storybook": "build-storybook",
|
|
33
|
+
"test": "jest",
|
|
34
|
+
"test:watch": "jest --watch",
|
|
35
|
+
"ts": "tsc --noEmit",
|
|
36
|
+
"changeset:version": "changeset version && npm i --lockfile-only"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"libphonenumber-js": "^1.9.44"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@babel/core": "^7.16.7",
|
|
43
|
+
"@babel/preset-env": "^7.16.8",
|
|
44
|
+
"@changesets/cli": "^2.19.0",
|
|
45
|
+
"@changesets/get-github-info": "^0.5.0",
|
|
46
|
+
"@changesets/types": "^4.0.2",
|
|
47
|
+
"@storybook/addon-a11y": "^6.4.13",
|
|
48
|
+
"@storybook/addon-actions": "^6.4.13",
|
|
49
|
+
"@storybook/addon-essentials": "^6.4.13",
|
|
50
|
+
"@storybook/addon-links": "^6.4.13",
|
|
51
|
+
"@storybook/addon-svelte-csf": "^1.1.0",
|
|
52
|
+
"@storybook/svelte": "^6.4.13",
|
|
53
|
+
"@sveltejs/adapter-static": "^1.0.0-next.26",
|
|
54
|
+
"@sveltejs/kit": "^1.0.0-next.229",
|
|
55
|
+
"@testing-library/jest-dom": "^5.16.1",
|
|
56
|
+
"@testing-library/svelte": "^3.0.3",
|
|
57
|
+
"@types/jest": "^27.4.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
59
|
+
"@typescript-eslint/parser": "^5.9.1",
|
|
60
|
+
"autoprefixer": "^10.4.2",
|
|
61
|
+
"babel-jest": "^27.4.6",
|
|
62
|
+
"babel-loader": "^8.2.3",
|
|
63
|
+
"commitizen": "^4.2.4",
|
|
64
|
+
"cssnano": "^5.0.15",
|
|
65
|
+
"dotenv": "^12.0.3",
|
|
66
|
+
"eslint": "^8.6.0",
|
|
67
|
+
"eslint-config-prettier": "^8.3.0",
|
|
68
|
+
"eslint-plugin-jest": "^25.7.0",
|
|
69
|
+
"eslint-plugin-svelte3": "^3.4.0",
|
|
70
|
+
"husky": "^7.0.4",
|
|
71
|
+
"jest": "^27.4.7",
|
|
72
|
+
"jest-matchmedia-mock": "^1.1.0",
|
|
73
|
+
"micromatch": "^4.0.4",
|
|
74
|
+
"postcss": "^8.4.5",
|
|
75
|
+
"postcss-load-config": "^3.1.1",
|
|
76
|
+
"prettier": "^2.5.1",
|
|
77
|
+
"prettier-plugin-svelte": "^2.6.0",
|
|
78
|
+
"standard-changelog": "^2.0.27",
|
|
79
|
+
"standard-version": "^9.3.2",
|
|
80
|
+
"storybook-dark-mode": "^1.0.8",
|
|
81
|
+
"svelte": "^3.46.2",
|
|
82
|
+
"svelte-check": "^2.3.0",
|
|
83
|
+
"svelte-inview": "^2.1.1",
|
|
84
|
+
"svelte-jester": "^2.1.5",
|
|
85
|
+
"svelte-loader": "^3.1.2",
|
|
86
|
+
"svelte-preprocess": "^4.10.1",
|
|
87
|
+
"svelte2tsx": "^0.4.14",
|
|
88
|
+
"tailwindcss": "^3.0.15",
|
|
89
|
+
"ts-jest": "^27.1.3",
|
|
90
|
+
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
91
|
+
"tslib": "^2.3.1",
|
|
92
|
+
"typescript": "^4.5.4"
|
|
93
|
+
},
|
|
94
|
+
"standard-version": {
|
|
95
|
+
"skip": {
|
|
96
|
+
"tag": true
|
|
97
|
+
},
|
|
98
|
+
"types": [
|
|
99
|
+
{
|
|
100
|
+
"type": "chore",
|
|
101
|
+
"section": "Others (chore)",
|
|
102
|
+
"hidden": false
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"type": "revert",
|
|
106
|
+
"section": "Reverts",
|
|
107
|
+
"hidden": false
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"type": "feat",
|
|
111
|
+
"section": "Features",
|
|
112
|
+
"hidden": false
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"type": "fix",
|
|
116
|
+
"section": "Bug Fixes",
|
|
117
|
+
"hidden": false
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"type": "improvement",
|
|
121
|
+
"section": "Feature Improvements",
|
|
122
|
+
"hidden": false
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "docs",
|
|
126
|
+
"section": "Docs",
|
|
127
|
+
"hidden": false
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"type": "style",
|
|
131
|
+
"section": "Styling",
|
|
132
|
+
"hidden": false
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"type": "refactor",
|
|
136
|
+
"section": "Code Refactoring",
|
|
137
|
+
"hidden": false
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"type": "perf",
|
|
141
|
+
"section": "Performance Improvements",
|
|
142
|
+
"hidden": false
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"type": "test",
|
|
146
|
+
"section": "Tests",
|
|
147
|
+
"hidden": false
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"type": "build",
|
|
151
|
+
"section": "Build System",
|
|
152
|
+
"hidden": false
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"type": "ci",
|
|
156
|
+
"section": "CI",
|
|
157
|
+
"hidden": false
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
"svelte": ".",
|
|
162
|
+
"type": "module",
|
|
163
|
+
"license": "UNLICENSED"
|
|
164
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const tailwindcss = require('tailwindcss');
|
|
2
|
+
const autoprefixer = require('autoprefixer');
|
|
3
|
+
const cssnano = require('cssnano');
|
|
4
|
+
|
|
5
|
+
const mode = process.env.NODE_ENV;
|
|
6
|
+
const dev = mode === 'development';
|
|
7
|
+
|
|
8
|
+
const config = {
|
|
9
|
+
plugins: [
|
|
10
|
+
//Some plugins, like tailwindcss/nesting, need to run before Tailwind,
|
|
11
|
+
tailwindcss(),
|
|
12
|
+
//But others, like autoprefixer, need to run after,
|
|
13
|
+
autoprefixer(),
|
|
14
|
+
!dev &&
|
|
15
|
+
cssnano({
|
|
16
|
+
preset: 'default'
|
|
17
|
+
})
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = config;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// taken from https://raw.githubusercontent.com/sveltejs/vite-plugin-svelte/master/scripts/changelog-github-custom.js
|
|
2
|
+
// based on https://github.com/atlassian/changesets/blob/main/packages/changelog-github/src/index.ts
|
|
3
|
+
// modifications to improve readability:
|
|
4
|
+
// - removed thanks notes. We're thanking contributors in the PRs or acknowledge their work in different ways
|
|
5
|
+
// - moved issue links to end of first line
|
|
6
|
+
|
|
7
|
+
const { config } = require('dotenv');
|
|
8
|
+
const { getInfo, getInfoFromPullRequest } = require('@changesets/get-github-info');
|
|
9
|
+
|
|
10
|
+
config();
|
|
11
|
+
|
|
12
|
+
const changelogFunctions = {
|
|
13
|
+
getDependencyReleaseLine: async (changesets, dependenciesUpdated, options) => {
|
|
14
|
+
if (!options.repo) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
if (dependenciesUpdated.length === 0) return '';
|
|
20
|
+
|
|
21
|
+
const changesetLink = `- Updated dependencies [${(
|
|
22
|
+
await Promise.all(
|
|
23
|
+
changesets.map(async (cs) => {
|
|
24
|
+
if (cs.commit) {
|
|
25
|
+
let { links } = await getInfo({
|
|
26
|
+
repo: options.repo,
|
|
27
|
+
commit: cs.commit
|
|
28
|
+
});
|
|
29
|
+
return links.commit;
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
.filter((_) => _)
|
|
35
|
+
.join(', ')}]:`;
|
|
36
|
+
|
|
37
|
+
const updatedDepenenciesList = dependenciesUpdated.map(
|
|
38
|
+
(dependency) => ` - ${dependency.name}@${dependency.newVersion}`
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return [changesetLink, ...updatedDepenenciesList].join('\n');
|
|
42
|
+
},
|
|
43
|
+
getReleaseLine: async (changeset, type, options) => {
|
|
44
|
+
if (!options || !options.repo) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let prFromSummary;
|
|
51
|
+
let commitFromSummary;
|
|
52
|
+
let usersFromSummary;
|
|
53
|
+
|
|
54
|
+
const replacedChangelog = changeset.summary
|
|
55
|
+
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
|
|
56
|
+
let num = Number(pr);
|
|
57
|
+
if (!isNaN(num)) prFromSummary = num;
|
|
58
|
+
return '';
|
|
59
|
+
})
|
|
60
|
+
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
|
|
61
|
+
commitFromSummary = commit;
|
|
62
|
+
return '';
|
|
63
|
+
})
|
|
64
|
+
.replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
|
|
65
|
+
usersFromSummary.push(user);
|
|
66
|
+
return '';
|
|
67
|
+
})
|
|
68
|
+
.trim();
|
|
69
|
+
|
|
70
|
+
const [firstLine, ...futureLines] = replacedChangelog.split('\n').map((l) => l.trimRight());
|
|
71
|
+
|
|
72
|
+
const links = await (async () => {
|
|
73
|
+
if (prFromSummary !== undefined) {
|
|
74
|
+
let { links } = await getInfoFromPullRequest({
|
|
75
|
+
repo: options.repo,
|
|
76
|
+
pull: prFromSummary
|
|
77
|
+
});
|
|
78
|
+
if (commitFromSummary) {
|
|
79
|
+
links = {
|
|
80
|
+
...links,
|
|
81
|
+
commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return links;
|
|
85
|
+
}
|
|
86
|
+
const commitToFetchFrom = commitFromSummary || changeset.commit;
|
|
87
|
+
if (commitToFetchFrom) {
|
|
88
|
+
let { links } = await getInfo({
|
|
89
|
+
repo: options.repo,
|
|
90
|
+
commit: commitToFetchFrom
|
|
91
|
+
});
|
|
92
|
+
return links;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
commit: null,
|
|
96
|
+
pull: null,
|
|
97
|
+
user: null
|
|
98
|
+
};
|
|
99
|
+
})();
|
|
100
|
+
|
|
101
|
+
const suffix = [
|
|
102
|
+
links.pull === null ? '' : ` (${links.pull})`
|
|
103
|
+
//links.commit === null ? '' : ` (${links.commit})`
|
|
104
|
+
].join('');
|
|
105
|
+
|
|
106
|
+
return `\n\n- ${firstLine}${suffix}\n${futureLines.map((l) => ` ${l}`).join('\n')}`;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
module.exports = changelogFunctions;
|