@internetarchive/recaptcha-manager 2.0.0 → 2.0.1
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/.claude/settings.local.json +7 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.editorconfig +29 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.github/workflows/ci.yml +27 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.github/workflows/gh-pages-main.yml +39 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.github/workflows/pr-preview.yml +63 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.husky/pre-commit +1 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.prettierignore +1 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/LICENSE +661 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/README.md +63 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/coverage/.gitignore +3 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/coverage/.placeholder +0 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/demo/app-root.ts +111 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/demo/index.html +21 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/eslint.config.mjs +53 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/index.ts +10 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/package-lock.json +11336 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/package.json +76 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/renovate.json +6 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/src/recaptcha-manager.ts +114 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/src/recaptcha-widget.ts +148 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/ssl/server.crt +22 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/ssl/server.key +28 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/test/mock-grecaptcha.ts +85 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/test/mock-lazy-loader.ts +36 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/test/recaptcha-manager.test.ts +201 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/tsconfig.json +31 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/vite.config.ts +25 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/web-dev-server.config.mjs +32 -0
- package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/web-test-runner.config.mjs +41 -0
- package/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/pr-preview.yml +63 -63
- package/.husky/pre-commit +1 -1
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +63 -63
- package/coverage/.gitignore +2 -2
- package/demo/app-root.ts +111 -111
- package/demo/index.html +21 -21
- package/dist/demo/app-root.js +31 -31
- package/dist/demo/app-root.js.map +1 -1
- package/dist/src/recaptcha-manager.d.ts +2 -1
- package/dist/src/recaptcha-manager.js +3 -2
- package/dist/src/recaptcha-manager.js.map +1 -1
- package/dist/test/mock-lazy-loader.js.map +1 -1
- package/dist/test/recaptcha-manager.test.js +1 -1
- package/dist/test/recaptcha-manager.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/package.json +76 -76
- package/renovate.json +6 -6
- package/src/recaptcha-manager.ts +114 -113
- package/ssl/server.key +28 -28
- package/test/mock-lazy-loader.ts +36 -36
- package/test/recaptcha-manager.test.ts +201 -199
- package/tsconfig.json +31 -31
- package/web-dev-server.config.mjs +32 -32
- package/web-test-runner.config.mjs +41 -41
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { MockGrecaptcha } from './mock-grecaptcha';
|
|
3
|
+
import { RecaptchaManager } from '../src/recaptcha-manager';
|
|
4
|
+
import { MockLazyLoaderService } from './mock-lazy-loader';
|
|
5
|
+
|
|
6
|
+
const mockLazyLoader = new MockLazyLoaderService();
|
|
7
|
+
|
|
8
|
+
describe('ReCaptcha Management', () => {
|
|
9
|
+
describe('ReCaptcha Manager', () => {
|
|
10
|
+
it('can return recaptchas', async () => {
|
|
11
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
12
|
+
mode: 'success',
|
|
13
|
+
});
|
|
14
|
+
mockGrecaptcha.response = 'foo';
|
|
15
|
+
const recaptchaManager = new RecaptchaManager({
|
|
16
|
+
lazyLoader: mockLazyLoader,
|
|
17
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
18
|
+
defaultSiteKey: '123',
|
|
19
|
+
});
|
|
20
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
21
|
+
const result = await recaptcha.execute();
|
|
22
|
+
expect(result).to.equal('foo');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('throws an error if no site key found', async () => {
|
|
26
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
27
|
+
mode: 'success',
|
|
28
|
+
});
|
|
29
|
+
mockGrecaptcha.response = 'foo';
|
|
30
|
+
const recaptchaManager = new RecaptchaManager({
|
|
31
|
+
lazyLoader: mockLazyLoader,
|
|
32
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
await recaptchaManager.getRecaptchaWidget();
|
|
36
|
+
expect.fail('should not get here');
|
|
37
|
+
} catch (e) {
|
|
38
|
+
expect((e as Error).message).to.equal(
|
|
39
|
+
'The reCaptcha widget requires a site key',
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('returns a cached version if one already exists for a given site key', async () => {
|
|
45
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
46
|
+
mode: 'success',
|
|
47
|
+
});
|
|
48
|
+
mockGrecaptcha.response = 'foo';
|
|
49
|
+
const recaptchaManager = new RecaptchaManager({
|
|
50
|
+
lazyLoader: mockLazyLoader,
|
|
51
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
52
|
+
defaultSiteKey: '123',
|
|
53
|
+
});
|
|
54
|
+
const recaptcha1 = await recaptchaManager.getRecaptchaWidget();
|
|
55
|
+
const recaptcha2 = await recaptchaManager.getRecaptchaWidget();
|
|
56
|
+
expect(recaptcha1).to.equal(recaptcha2);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('loads the recaptcha library if needed', async () => {
|
|
60
|
+
// Mock lazy loader that mimics the grecaptcha script calling the callback on load
|
|
61
|
+
const mockLazyLoaderWithCallback = new MockLazyLoaderService(() => {
|
|
62
|
+
window.grecaptcha = new MockGrecaptcha({
|
|
63
|
+
mode: 'success',
|
|
64
|
+
});
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
(window as any).grecaptchaLoadedCallback();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const recaptchaManager = new RecaptchaManager({
|
|
70
|
+
lazyLoader: mockLazyLoaderWithCallback,
|
|
71
|
+
defaultSiteKey: '123',
|
|
72
|
+
timeout: 100,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await recaptchaManager.getRecaptchaWidget();
|
|
76
|
+
const loadUrl = mockLazyLoaderWithCallback.loadScriptSrc;
|
|
77
|
+
expect(
|
|
78
|
+
loadUrl?.includes(
|
|
79
|
+
'https://www.recaptcha.net/recaptcha/api.js?onload=grecaptchaLoadedCallback',
|
|
80
|
+
),
|
|
81
|
+
).to.be.true;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('rejects after specified timeout if grecaptcha fails to execute callback', async () => {
|
|
85
|
+
const recaptchaManager = new RecaptchaManager({
|
|
86
|
+
lazyLoader: mockLazyLoader,
|
|
87
|
+
defaultSiteKey: '123',
|
|
88
|
+
timeout: 100,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
await recaptchaManager.getRecaptchaWidget();
|
|
93
|
+
expect.fail('recaptcha load did not time out as expected');
|
|
94
|
+
} catch (err) {
|
|
95
|
+
expect(err).to.be.instanceOf(Error);
|
|
96
|
+
expect((err as Error).message).to.equal(
|
|
97
|
+
'grecaptcha failed to execute callback',
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('can set the timeout delay', async () => {
|
|
103
|
+
const recaptchaManager = new RecaptchaManager({
|
|
104
|
+
lazyLoader: mockLazyLoader,
|
|
105
|
+
defaultSiteKey: '123',
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
recaptchaManager.setTimeoutDelay(1);
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
await recaptchaManager.getRecaptchaWidget();
|
|
112
|
+
expect.fail('recaptcha load did not time out as expected');
|
|
113
|
+
} catch (err) {
|
|
114
|
+
expect(err).to.be.instanceOf(Error);
|
|
115
|
+
expect((err as Error).message).to.equal(
|
|
116
|
+
'grecaptcha failed to execute callback',
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('ReCaptcha Widget', () => {
|
|
123
|
+
it('can error properly like a Promise', async () => {
|
|
124
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
125
|
+
mode: 'error',
|
|
126
|
+
});
|
|
127
|
+
const recaptchaManager = new RecaptchaManager({
|
|
128
|
+
lazyLoader: mockLazyLoader,
|
|
129
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
130
|
+
defaultSiteKey: '123',
|
|
131
|
+
});
|
|
132
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
await recaptcha.execute();
|
|
136
|
+
expect.fail('should not get here');
|
|
137
|
+
} catch (error) {
|
|
138
|
+
expect((error as Error).message).to.equal('error');
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('can expire properly like a Promise', async () => {
|
|
143
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
144
|
+
mode: 'expired',
|
|
145
|
+
});
|
|
146
|
+
const recaptchaManager = new RecaptchaManager({
|
|
147
|
+
lazyLoader: mockLazyLoader,
|
|
148
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
149
|
+
defaultSiteKey: '123',
|
|
150
|
+
});
|
|
151
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
await recaptcha.execute();
|
|
155
|
+
expect.fail('should not get here');
|
|
156
|
+
} catch (error) {
|
|
157
|
+
expect((error as Error).message).to.equal('expired');
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('resets the captcha after execution', async () => {
|
|
162
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
163
|
+
mode: 'success',
|
|
164
|
+
addDelay: true,
|
|
165
|
+
});
|
|
166
|
+
const recaptchaManager = new RecaptchaManager({
|
|
167
|
+
lazyLoader: mockLazyLoader,
|
|
168
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
169
|
+
defaultSiteKey: '123',
|
|
170
|
+
});
|
|
171
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
172
|
+
|
|
173
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
174
|
+
await recaptcha.execute();
|
|
175
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(1);
|
|
176
|
+
await recaptcha.execute();
|
|
177
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(2);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// there's no way to know if the user has dismissed the captcha so if another execution
|
|
181
|
+
// comes through while the captcha is still active, it will be reset
|
|
182
|
+
it('resets the captcha if another execution gets called', async () => {
|
|
183
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
184
|
+
mode: 'success',
|
|
185
|
+
addDelay: true,
|
|
186
|
+
});
|
|
187
|
+
const recaptchaManager = new RecaptchaManager({
|
|
188
|
+
lazyLoader: mockLazyLoader,
|
|
189
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
190
|
+
defaultSiteKey: '123',
|
|
191
|
+
});
|
|
192
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
193
|
+
|
|
194
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
195
|
+
recaptcha.execute();
|
|
196
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
197
|
+
await recaptcha.execute();
|
|
198
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(2);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": ["es2017", "dom"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"outDir": "dist",
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"inlineSources": true,
|
|
16
|
+
"rootDir": "./",
|
|
17
|
+
"declaration": true,
|
|
18
|
+
"plugins": [
|
|
19
|
+
{
|
|
20
|
+
"name": "ts-lit-plugin"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"paths": {
|
|
24
|
+
// workaround for: https://github.com/vitest-dev/vitest/issues/4567
|
|
25
|
+
"rollup/parseAst": [
|
|
26
|
+
"./node_modules/rollup/dist/parseAst"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"include": ["**/*.ts"]
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
// https://vitejs.dev/config/
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
base: './',
|
|
7
|
+
root: resolve(__dirname, './demo'),
|
|
8
|
+
build: {
|
|
9
|
+
/**
|
|
10
|
+
* This is the directory where the built files will be placed
|
|
11
|
+
* that we upload to GitHub Pages.
|
|
12
|
+
*/
|
|
13
|
+
outDir: '../ghpages/demo',
|
|
14
|
+
emptyOutDir: true,
|
|
15
|
+
manifest: true,
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
input: {
|
|
18
|
+
main: resolve(__dirname, 'demo/index.html'),
|
|
19
|
+
},
|
|
20
|
+
output: {
|
|
21
|
+
entryFileNames: 'app-root.js',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
|
|
2
|
+
|
|
3
|
+
/** Use Hot Module replacement by adding --hmr to the start command */
|
|
4
|
+
const hmr = process.argv.includes('--hmr');
|
|
5
|
+
|
|
6
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
7
|
+
nodeResolve: true,
|
|
8
|
+
open: '/demo',
|
|
9
|
+
watch: !hmr,
|
|
10
|
+
sslCert: './ssl/server.crt',
|
|
11
|
+
sslKey: './ssl/server.key',
|
|
12
|
+
hostname: 'local.archive.org',
|
|
13
|
+
http2: true,
|
|
14
|
+
|
|
15
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
16
|
+
// esbuildTarget: 'auto'
|
|
17
|
+
|
|
18
|
+
/** Set appIndex to enable SPA routing */
|
|
19
|
+
// appIndex: 'demo/index.html',
|
|
20
|
+
|
|
21
|
+
/** Configure bare import resolve plugin */
|
|
22
|
+
// nodeResolve: {
|
|
23
|
+
// exportConditions: ['browser', 'development']
|
|
24
|
+
// },
|
|
25
|
+
|
|
26
|
+
plugins: [
|
|
27
|
+
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
28
|
+
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
// See documentation for all available options
|
|
32
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
2
|
+
|
|
3
|
+
const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
|
|
4
|
+
|
|
5
|
+
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
6
|
+
/** Test files to run */
|
|
7
|
+
files: 'dist/test/**/*.test.js',
|
|
8
|
+
|
|
9
|
+
/** Resolve bare module imports */
|
|
10
|
+
nodeResolve: {
|
|
11
|
+
exportConditions: ['browser', 'development'],
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
/** Filter out lit dev mode logs */
|
|
15
|
+
filterBrowserLogs(log) {
|
|
16
|
+
for (const arg of log.args) {
|
|
17
|
+
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
25
|
+
// esbuildTarget: 'auto',
|
|
26
|
+
|
|
27
|
+
/** Amount of browsers to run concurrently */
|
|
28
|
+
// concurrentBrowsers: 2,
|
|
29
|
+
|
|
30
|
+
/** Amount of test files per browser to test concurrently */
|
|
31
|
+
// concurrency: 1,
|
|
32
|
+
|
|
33
|
+
/** Browsers to run tests on */
|
|
34
|
+
// browsers: [
|
|
35
|
+
// playwrightLauncher({ product: 'chromium' }),
|
|
36
|
+
// playwrightLauncher({ product: 'firefox' }),
|
|
37
|
+
// playwrightLauncher({ product: 'webkit' }),
|
|
38
|
+
// ],
|
|
39
|
+
|
|
40
|
+
// See documentation for all available options
|
|
41
|
+
});
|
package/.editorconfig
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# EditorConfig helps developers define and maintain consistent
|
|
2
|
-
# coding styles between different editors and IDEs
|
|
3
|
-
# editorconfig.org
|
|
4
|
-
|
|
5
|
-
root = true
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[*]
|
|
9
|
-
|
|
10
|
-
# Change these settings to your own preference
|
|
11
|
-
indent_style = space
|
|
12
|
-
indent_size = 2
|
|
13
|
-
|
|
14
|
-
# We recommend you to keep these unchanged
|
|
15
|
-
end_of_line = lf
|
|
16
|
-
charset = utf-8
|
|
17
|
-
trim_trailing_whitespace = true
|
|
18
|
-
insert_final_newline = true
|
|
19
|
-
|
|
20
|
-
[*.md]
|
|
21
|
-
trim_trailing_whitespace = false
|
|
22
|
-
|
|
23
|
-
[*.json]
|
|
24
|
-
indent_size = 2
|
|
25
|
-
|
|
26
|
-
[*.{html,js,md}]
|
|
27
|
-
block_comment_start = /**
|
|
28
|
-
block_comment = *
|
|
29
|
-
block_comment_end = */
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
|
2
|
+
# coding styles between different editors and IDEs
|
|
3
|
+
# editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[*]
|
|
9
|
+
|
|
10
|
+
# Change these settings to your own preference
|
|
11
|
+
indent_style = space
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
# We recommend you to keep these unchanged
|
|
15
|
+
end_of_line = lf
|
|
16
|
+
charset = utf-8
|
|
17
|
+
trim_trailing_whitespace = true
|
|
18
|
+
insert_final_newline = true
|
|
19
|
+
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
|
|
23
|
+
[*.json]
|
|
24
|
+
indent_size = 2
|
|
25
|
+
|
|
26
|
+
[*.{html,js,md}]
|
|
27
|
+
block_comment_start = /**
|
|
28
|
+
block_comment = *
|
|
29
|
+
block_comment_end = */
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
name: App CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ main ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ main ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
- uses: actions/setup-node@v4
|
|
16
|
-
with:
|
|
17
|
-
node-version: latest
|
|
18
|
-
|
|
19
|
-
- name: Install dependencies
|
|
20
|
-
run: npm install
|
|
21
|
-
|
|
22
|
-
- name: Run tests
|
|
23
|
-
run: npm run test
|
|
24
|
-
|
|
25
|
-
- uses: codecov/codecov-action@v5
|
|
26
|
-
with:
|
|
27
|
-
token: ${{ secrets.CODECOV_TOKEN }}
|
|
1
|
+
name: App CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: latest
|
|
18
|
+
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: npm install
|
|
21
|
+
|
|
22
|
+
- name: Run tests
|
|
23
|
+
run: npm run test
|
|
24
|
+
|
|
25
|
+
- uses: codecov/codecov-action@v5
|
|
26
|
+
with:
|
|
27
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
# This workflow will generate the static page under `main` subdirectory inside the `gh-pages` branch
|
|
2
|
-
|
|
3
|
-
# This workflow will run every time new changes were pushed to the `main` branch
|
|
4
|
-
|
|
5
|
-
name: App build CI/CD to main branch
|
|
6
|
-
|
|
7
|
-
on:
|
|
8
|
-
push:
|
|
9
|
-
branches: [ main ]
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
build:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
with:
|
|
18
|
-
persist-credentials: false
|
|
19
|
-
- uses: actions/setup-node@v4
|
|
20
|
-
with:
|
|
21
|
-
node-version: latest
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm install
|
|
26
|
-
|
|
27
|
-
- name: Create build files for gh-pages deploy
|
|
28
|
-
run: npm run ghpages:build
|
|
29
|
-
|
|
30
|
-
# Reference: https://github.com/JamesIves/github-pages-deploy-action
|
|
31
|
-
- name: Deploy 🚀
|
|
32
|
-
uses: JamesIves/github-pages-deploy-action@v4.5.0
|
|
33
|
-
with:
|
|
34
|
-
branch: gh-pages
|
|
35
|
-
folder: ghpages
|
|
36
|
-
clean-exclude: pr/
|
|
37
|
-
force: false
|
|
38
|
-
target-folder: main
|
|
39
|
-
token: ${{ secrets.GH_TOKEN }}
|
|
1
|
+
# This workflow will generate the static page under `main` subdirectory inside the `gh-pages` branch
|
|
2
|
+
|
|
3
|
+
# This workflow will run every time new changes were pushed to the `main` branch
|
|
4
|
+
|
|
5
|
+
name: App build CI/CD to main branch
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches: [ main ]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
persist-credentials: false
|
|
19
|
+
- uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: latest
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: npm install
|
|
26
|
+
|
|
27
|
+
- name: Create build files for gh-pages deploy
|
|
28
|
+
run: npm run ghpages:build
|
|
29
|
+
|
|
30
|
+
# Reference: https://github.com/JamesIves/github-pages-deploy-action
|
|
31
|
+
- name: Deploy 🚀
|
|
32
|
+
uses: JamesIves/github-pages-deploy-action@v4.5.0
|
|
33
|
+
with:
|
|
34
|
+
branch: gh-pages
|
|
35
|
+
folder: ghpages
|
|
36
|
+
clean-exclude: pr/
|
|
37
|
+
force: false
|
|
38
|
+
target-folder: main
|
|
39
|
+
token: ${{ secrets.GH_TOKEN }}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# This workflow will generate the static page under `pr` subdirectory inside the `gh-pages` branch
|
|
2
|
-
|
|
3
|
-
# This workflow will run every time there's a PR opened, reopened, synchronize, or closed
|
|
4
|
-
|
|
5
|
-
name: Deploy PR previews
|
|
6
|
-
|
|
7
|
-
on:
|
|
8
|
-
pull_request:
|
|
9
|
-
types:
|
|
10
|
-
- opened
|
|
11
|
-
- reopened
|
|
12
|
-
- synchronize
|
|
13
|
-
- closed
|
|
14
|
-
|
|
15
|
-
concurrency: preview-${{ github.ref }}
|
|
16
|
-
|
|
17
|
-
env:
|
|
18
|
-
PREVIEW_BRANCH: gh-pages
|
|
19
|
-
jobs:
|
|
20
|
-
deploy-preview:
|
|
21
|
-
runs-on: ubuntu-latest
|
|
22
|
-
steps:
|
|
23
|
-
- name: Checkout
|
|
24
|
-
uses: actions/checkout@v4
|
|
25
|
-
- uses: actions/setup-node@v4
|
|
26
|
-
with:
|
|
27
|
-
node-version: latest
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- name: Install and Build
|
|
31
|
-
run: |
|
|
32
|
-
npm install
|
|
33
|
-
npm run ghpages:build
|
|
34
|
-
|
|
35
|
-
# Reference: https://github.com/rossjrw/pr-preview-action
|
|
36
|
-
- name: Deploy preview
|
|
37
|
-
uses: rossjrw/pr-preview-action@v1
|
|
38
|
-
id: preview-step
|
|
39
|
-
with:
|
|
40
|
-
source-dir: ./ghpages/
|
|
41
|
-
umbrella-dir: pr
|
|
42
|
-
preview-branch: ${{ env.PREVIEW_BRANCH }}
|
|
43
|
-
comment: false
|
|
44
|
-
|
|
45
|
-
- uses: marocchino/sticky-pull-request-comment@v2
|
|
46
|
-
if: steps.preview-step.outputs.deployment-action == 'deploy'
|
|
47
|
-
with:
|
|
48
|
-
header: pr-preview
|
|
49
|
-
message: |
|
|
50
|
-
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) ${{ steps.preview-step.outputs.action-version }}
|
|
51
|
-
:---:
|
|
52
|
-
| <p></p> :rocket: View preview at <br> ${{ steps.preview-step.outputs.preview-url }}demo/ <br><br>
|
|
53
|
-
| <h6>Built to branch [`${{ env.PREVIEW_BRANCH }}`](${{ github.server_url }}/${{ github.repository }}/tree/${{ env.PREVIEW_BRANCH }}) at ${{ steps.preview-step.outputs.action-start-time }}. <br> Preview will be ready when the [GitHub Pages deployment](${{ github.server_url }}/${{ github.repository }}/deployments) is complete. <br><br> </h6>
|
|
54
|
-
|
|
55
|
-
- uses: marocchino/sticky-pull-request-comment@v2
|
|
56
|
-
if: steps.preview-step.outputs.deployment-action == 'remove'
|
|
57
|
-
with:
|
|
58
|
-
header: pr-preview
|
|
59
|
-
message: |
|
|
60
|
-
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) ${{ steps.preview-step.outputs.action-version }}
|
|
61
|
-
:---:
|
|
62
|
-
Preview removed because the pull request was closed.
|
|
63
|
-
${{ steps.preview-step.outputs.action-start-time }}
|
|
1
|
+
# This workflow will generate the static page under `pr` subdirectory inside the `gh-pages` branch
|
|
2
|
+
|
|
3
|
+
# This workflow will run every time there's a PR opened, reopened, synchronize, or closed
|
|
4
|
+
|
|
5
|
+
name: Deploy PR previews
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
types:
|
|
10
|
+
- opened
|
|
11
|
+
- reopened
|
|
12
|
+
- synchronize
|
|
13
|
+
- closed
|
|
14
|
+
|
|
15
|
+
concurrency: preview-${{ github.ref }}
|
|
16
|
+
|
|
17
|
+
env:
|
|
18
|
+
PREVIEW_BRANCH: gh-pages
|
|
19
|
+
jobs:
|
|
20
|
+
deploy-preview:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
- uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: latest
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
- name: Install and Build
|
|
31
|
+
run: |
|
|
32
|
+
npm install
|
|
33
|
+
npm run ghpages:build
|
|
34
|
+
|
|
35
|
+
# Reference: https://github.com/rossjrw/pr-preview-action
|
|
36
|
+
- name: Deploy preview
|
|
37
|
+
uses: rossjrw/pr-preview-action@v1
|
|
38
|
+
id: preview-step
|
|
39
|
+
with:
|
|
40
|
+
source-dir: ./ghpages/
|
|
41
|
+
umbrella-dir: pr
|
|
42
|
+
preview-branch: ${{ env.PREVIEW_BRANCH }}
|
|
43
|
+
comment: false
|
|
44
|
+
|
|
45
|
+
- uses: marocchino/sticky-pull-request-comment@v2
|
|
46
|
+
if: steps.preview-step.outputs.deployment-action == 'deploy'
|
|
47
|
+
with:
|
|
48
|
+
header: pr-preview
|
|
49
|
+
message: |
|
|
50
|
+
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) ${{ steps.preview-step.outputs.action-version }}
|
|
51
|
+
:---:
|
|
52
|
+
| <p></p> :rocket: View preview at <br> ${{ steps.preview-step.outputs.preview-url }}demo/ <br><br>
|
|
53
|
+
| <h6>Built to branch [`${{ env.PREVIEW_BRANCH }}`](${{ github.server_url }}/${{ github.repository }}/tree/${{ env.PREVIEW_BRANCH }}) at ${{ steps.preview-step.outputs.action-start-time }}. <br> Preview will be ready when the [GitHub Pages deployment](${{ github.server_url }}/${{ github.repository }}/deployments) is complete. <br><br> </h6>
|
|
54
|
+
|
|
55
|
+
- uses: marocchino/sticky-pull-request-comment@v2
|
|
56
|
+
if: steps.preview-step.outputs.deployment-action == 'remove'
|
|
57
|
+
with:
|
|
58
|
+
header: pr-preview
|
|
59
|
+
message: |
|
|
60
|
+
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) ${{ steps.preview-step.outputs.action-version }}
|
|
61
|
+
:---:
|
|
62
|
+
Preview removed because the pull request was closed.
|
|
63
|
+
${{ steps.preview-step.outputs.action-start-time }}
|
package/.husky/pre-commit
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
npx lint-staged
|
|
1
|
+
npx lint-staged
|
package/.prettierignore
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
coverage
|
|
1
|
+
coverage
|