@regardio/dev 1.24.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/README.md +2 -2
- package/dist/bin/ship/hotfix.bin.mjs +140 -0
- package/dist/bin/ship/production.bin.mjs +120 -0
- package/dist/bin/ship/staging.bin.mjs +70 -0
- package/dist/bin/ship/utils-BQ-JZ2D5.mjs +45 -0
- package/dist/playwright/index.d.mts +24 -0
- package/dist/playwright/index.mjs +61 -0
- package/dist/vitest/node.d.mts +22 -0
- package/dist/vitest/node.mjs +28 -0
- package/dist/vitest/react.d.mts +22 -0
- package/dist/vitest/react.mjs +28 -0
- package/docs/en/README.md +95 -0
- package/docs/en/agents.md +57 -0
- package/docs/en/standards/api.md +324 -0
- package/docs/en/standards/coding.md +144 -0
- package/docs/en/standards/commits.md +111 -0
- package/docs/en/standards/documentation.md +173 -0
- package/docs/en/standards/naming.md +180 -0
- package/docs/en/standards/principles.md +84 -0
- package/docs/en/standards/react.md +246 -0
- package/docs/en/standards/sql.md +258 -0
- package/docs/en/standards/testing.md +139 -0
- package/docs/en/standards/writing.md +119 -0
- package/docs/en/tools/biome.md +89 -0
- package/docs/en/tools/commitlint.md +92 -0
- package/docs/en/tools/dependencies.md +116 -0
- package/docs/en/tools/husky.md +90 -0
- package/docs/en/tools/markdownlint.md +84 -0
- package/docs/en/tools/playwright.md +117 -0
- package/docs/en/tools/releases.md +242 -0
- package/docs/en/tools/typescript.md +89 -0
- package/docs/en/tools/vitest.md +146 -0
- package/package.json +58 -70
- package/src/biome/preset.json +3 -0
- package/templates/changeset/README.md +14 -0
- package/templates/changeset/config.json +11 -0
- package/templates/github/release.yml +77 -0
- package/dist/bin/exec/clean.d.ts +0 -3
- package/dist/bin/exec/clean.d.ts.map +0 -1
- package/dist/bin/exec/clean.js +0 -25
- package/dist/bin/exec/clean.test.d.ts +0 -2
- package/dist/bin/exec/clean.test.d.ts.map +0 -1
- package/dist/bin/exec/clean.test.js +0 -45
- package/dist/bin/exec/husky.d.ts +0 -3
- package/dist/bin/exec/husky.d.ts.map +0 -1
- package/dist/bin/exec/husky.js +0 -9
- package/dist/bin/exec/p.d.ts +0 -3
- package/dist/bin/exec/p.d.ts.map +0 -1
- package/dist/bin/exec/p.js +0 -8
- package/dist/bin/exec/s.d.ts +0 -3
- package/dist/bin/exec/s.d.ts.map +0 -1
- package/dist/bin/exec/s.js +0 -8
- package/dist/bin/exec/tsc.d.ts +0 -3
- package/dist/bin/exec/tsc.d.ts.map +0 -1
- package/dist/bin/exec/tsc.js +0 -8
- package/dist/bin/lint/biome.d.ts +0 -3
- package/dist/bin/lint/biome.d.ts.map +0 -1
- package/dist/bin/lint/biome.js +0 -8
- package/dist/bin/lint/commit.d.ts +0 -3
- package/dist/bin/lint/commit.d.ts.map +0 -1
- package/dist/bin/lint/commit.js +0 -8
- package/dist/bin/lint/md.d.ts +0 -3
- package/dist/bin/lint/md.d.ts.map +0 -1
- package/dist/bin/lint/md.js +0 -16
- package/dist/bin/lint/package.d.ts +0 -4
- package/dist/bin/lint/package.d.ts.map +0 -1
- package/dist/bin/lint/package.js +0 -81
- package/dist/bin/lint/package.test.d.ts +0 -2
- package/dist/bin/lint/package.test.d.ts.map +0 -1
- package/dist/bin/lint/package.test.js +0 -65
- package/dist/bin/ship/hotfix.d.ts +0 -3
- package/dist/bin/ship/hotfix.d.ts.map +0 -1
- package/dist/bin/ship/hotfix.js +0 -141
- package/dist/bin/ship/production.d.ts +0 -3
- package/dist/bin/ship/production.d.ts.map +0 -1
- package/dist/bin/ship/production.js +0 -124
- package/dist/bin/ship/staging.d.ts +0 -3
- package/dist/bin/ship/staging.d.ts.map +0 -1
- package/dist/bin/ship/staging.js +0 -51
- package/dist/bin/ship/utils.d.ts +0 -9
- package/dist/bin/ship/utils.d.ts.map +0 -1
- package/dist/bin/ship/utils.js +0 -63
- package/dist/bin/ship/utils.test.d.ts +0 -2
- package/dist/bin/ship/utils.test.d.ts.map +0 -1
- package/dist/bin/ship/utils.test.js +0 -127
- package/dist/config.test.d.ts +0 -2
- package/dist/config.test.d.ts.map +0 -1
- package/dist/config.test.js +0 -101
- package/dist/playwright/index.d.ts +0 -10
- package/dist/playwright/index.d.ts.map +0 -1
- package/dist/playwright/index.js +0 -42
- package/dist/playwright/index.test.d.ts +0 -2
- package/dist/playwright/index.test.d.ts.map +0 -1
- package/dist/playwright/index.test.js +0 -55
- package/dist/testing/setup-react.d.ts +0 -2
- package/dist/testing/setup-react.d.ts.map +0 -1
- package/dist/testing/setup-react.js +0 -1
- package/dist/vitest/node.d.ts +0 -22
- package/dist/vitest/node.d.ts.map +0 -1
- package/dist/vitest/node.js +0 -16
- package/dist/vitest/react.d.ts +0 -17
- package/dist/vitest/react.d.ts.map +0 -1
- package/dist/vitest/react.js +0 -12
- package/src/bin/exec/clean.test.ts +0 -63
- package/src/bin/exec/clean.ts +0 -36
- package/src/bin/exec/husky.ts +0 -14
- package/src/bin/exec/p.ts +0 -13
- package/src/bin/exec/s.ts +0 -13
- package/src/bin/exec/tsc.ts +0 -13
- package/src/bin/lint/biome.ts +0 -13
- package/src/bin/lint/commit.ts +0 -13
- package/src/bin/lint/md.ts +0 -28
- package/src/bin/lint/package.test.ts +0 -83
- package/src/bin/lint/package.ts +0 -108
- package/src/bin/ship/hotfix.ts +0 -241
- package/src/bin/ship/production.ts +0 -240
- package/src/bin/ship/staging.ts +0 -108
- package/src/bin/ship/utils.test.ts +0 -178
- package/src/bin/ship/utils.ts +0 -109
- package/src/config.test.ts +0 -129
- package/src/markdownlint/markdownlint-cli2.jsonc +0 -9
- package/src/playwright/index.test.ts +0 -73
- package/src/playwright/index.ts +0 -63
- package/src/templates/release.yml +0 -128
- package/src/testing/setup-react.ts +0 -8
- package/src/vitest/node.ts +0 -25
- package/src/vitest/react.ts +0 -19
- /package/{src → templates}/sqlfluff/setup.cfg +0 -0
package/src/config.test.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { describe, expect, it } from 'vitest';
|
|
5
|
-
|
|
6
|
-
const srcDir = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
function readJson(filePath: string) {
|
|
9
|
-
// biome-ignore lint/suspicious/noExplicitAny: Test file needs flexible typing for nested config access
|
|
10
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf8')) as any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe('Config Structure Validation', () => {
|
|
14
|
-
describe('biome/preset.json', () => {
|
|
15
|
-
const configPath = path.join(srcDir, 'biome/preset.json');
|
|
16
|
-
const config = readJson(configPath);
|
|
17
|
-
|
|
18
|
-
it('has $schema defined', () => {
|
|
19
|
-
expect(config.$schema).toContain('biomejs.dev');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('has linter enabled', () => {
|
|
23
|
-
expect(config.linter?.enabled).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('has formatter enabled', () => {
|
|
27
|
-
expect(config.formatter?.enabled).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('has recommended rules enabled', () => {
|
|
31
|
-
expect(config.linter?.rules?.recommended).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('disallows explicit any', () => {
|
|
35
|
-
expect(config.linter?.rules?.suspicious?.noExplicitAny).toBe('error');
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('typescript/base.json', () => {
|
|
40
|
-
const configPath = path.join(srcDir, 'typescript/base.json');
|
|
41
|
-
const config = readJson(configPath);
|
|
42
|
-
|
|
43
|
-
it('has $schema defined', () => {
|
|
44
|
-
expect(config.$schema).toContain('schemastore.org');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('has strict mode enabled', () => {
|
|
48
|
-
expect(config.compilerOptions?.strict).toBe(true);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('has noUncheckedIndexedAccess enabled', () => {
|
|
52
|
-
expect(config.compilerOptions?.noUncheckedIndexedAccess).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('has strictNullChecks enabled', () => {
|
|
56
|
-
expect(config.compilerOptions?.strictNullChecks).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('has noImplicitAny enabled', () => {
|
|
60
|
-
expect(config.compilerOptions?.noImplicitAny).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('targets ES2022', () => {
|
|
64
|
-
expect(config.compilerOptions?.target).toBe('ES2022');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('uses ESNext module', () => {
|
|
68
|
-
expect(config.compilerOptions?.module).toBe('ESNext');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('typescript/react.json', () => {
|
|
73
|
-
const configPath = path.join(srcDir, 'typescript/react.json');
|
|
74
|
-
const config = readJson(configPath);
|
|
75
|
-
|
|
76
|
-
it('extends base.json', () => {
|
|
77
|
-
expect(config.extends).toContain('./base.json');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('has jsx set to react-jsx', () => {
|
|
81
|
-
expect(config.compilerOptions?.jsx).toBe('react-jsx');
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe('markdownlint/markdownlint.json', () => {
|
|
86
|
-
const configPath = path.join(srcDir, 'markdownlint/markdownlint.json');
|
|
87
|
-
const config = readJson(configPath);
|
|
88
|
-
|
|
89
|
-
it('is a valid JSON object', () => {
|
|
90
|
-
expect(typeof config).toBe('object');
|
|
91
|
-
expect(config).not.toBeNull();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('has MD013 (line-length) rule configured', () => {
|
|
95
|
-
expect(config.MD013).toBeDefined();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('commitlint/commitlint.cjs', () => {
|
|
100
|
-
const configPath = path.join(srcDir, 'commitlint/commitlint.cjs');
|
|
101
|
-
|
|
102
|
-
it('file exists', () => {
|
|
103
|
-
expect(fs.existsSync(configPath)).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('exports extends with conventional config', () => {
|
|
107
|
-
const content = fs.readFileSync(configPath, 'utf8');
|
|
108
|
-
expect(content).toContain('@commitlint/config-conventional');
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe('Vitest Configs', () => {
|
|
114
|
-
describe('vitest/node', () => {
|
|
115
|
-
it('exports vitestNodeConfig', async () => {
|
|
116
|
-
const { vitestNodeConfig } = await import('./vitest/node.js');
|
|
117
|
-
expect(vitestNodeConfig).toBeDefined();
|
|
118
|
-
expect(vitestNodeConfig.environment).toBe('node');
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('vitest/react', () => {
|
|
123
|
-
it('exports vitestReactConfig', async () => {
|
|
124
|
-
const { vitestReactConfig } = await import('./vitest/react.js');
|
|
125
|
-
expect(vitestReactConfig).toBeDefined();
|
|
126
|
-
expect(vitestReactConfig.environment).toBe('jsdom');
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/main/schema/markdownlint-cli2-config-schema.json",
|
|
3
|
-
"config": {
|
|
4
|
-
"extends": "./markdownlint.json"
|
|
5
|
-
},
|
|
6
|
-
"frontMatter": "(^---\\s*$[^]*?^---\\s*$)(\\r\\n|\\r|\\n|$)",
|
|
7
|
-
"globs": ["**/*.md", "**/*.mdoc", "**/*.mdx"],
|
|
8
|
-
"ignores": ["**/node_modules/**", "**/dist/**"]
|
|
9
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { devices } from '@playwright/test';
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import type { BuildPlaywrightBaseConfigParams } from './index.js';
|
|
4
|
-
import { buildPlaywrightBaseConfig } from './index.js';
|
|
5
|
-
|
|
6
|
-
describe('buildPlaywrightBaseConfig', () => {
|
|
7
|
-
const validParams: BuildPlaywrightBaseConfigParams = {
|
|
8
|
-
appPort: 3000,
|
|
9
|
-
appUrl: 'http://localhost:3000',
|
|
10
|
-
devices,
|
|
11
|
-
webServerCommand: 'pnpm dev',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
describe('validation', () => {
|
|
15
|
-
it('throws if appUrl is missing', () => {
|
|
16
|
-
expect(() => buildPlaywrightBaseConfig({ ...validParams, appUrl: '' })).toThrow(
|
|
17
|
-
'[playwright] appUrl must be a non-empty string',
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('throws if appPort is not a number', () => {
|
|
22
|
-
expect(() =>
|
|
23
|
-
buildPlaywrightBaseConfig({ ...validParams, appPort: '3000' as unknown as number }),
|
|
24
|
-
).toThrow('[playwright] appPort must be a number');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('throws if devices is missing', () => {
|
|
28
|
-
expect(() =>
|
|
29
|
-
buildPlaywrightBaseConfig({
|
|
30
|
-
...validParams,
|
|
31
|
-
devices: undefined as unknown as typeof devices,
|
|
32
|
-
}),
|
|
33
|
-
).toThrow('[playwright] devices must be provided');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('config output', () => {
|
|
38
|
-
it('returns valid Playwright config structure', () => {
|
|
39
|
-
const config = buildPlaywrightBaseConfig(validParams);
|
|
40
|
-
|
|
41
|
-
expect(config).toHaveProperty('projects');
|
|
42
|
-
expect(config).toHaveProperty('testDir', './tests');
|
|
43
|
-
expect(config).toHaveProperty('testMatch', '**/*.e2e.ts');
|
|
44
|
-
expect(config).toHaveProperty('webServer');
|
|
45
|
-
expect(config).toHaveProperty('use.baseURL', 'http://localhost:3000');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('configures 6 browser projects', () => {
|
|
49
|
-
const config = buildPlaywrightBaseConfig(validParams);
|
|
50
|
-
expect(config.projects).toHaveLength(6);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('sets retries to 0 when not in CI', () => {
|
|
54
|
-
const config = buildPlaywrightBaseConfig({ ...validParams, ci: false });
|
|
55
|
-
expect(config.retries).toBe(0);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('sets retries to 2 in CI', () => {
|
|
59
|
-
const config = buildPlaywrightBaseConfig({ ...validParams, ci: true });
|
|
60
|
-
expect(config.retries).toBe(2);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('sets workers to 1 in CI', () => {
|
|
64
|
-
const config = buildPlaywrightBaseConfig({ ...validParams, ci: true });
|
|
65
|
-
expect(config.workers).toBe(1);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('sets forbidOnly to true in CI', () => {
|
|
69
|
-
const config = buildPlaywrightBaseConfig({ ...validParams, ci: true });
|
|
70
|
-
expect(config.forbidOnly).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
package/src/playwright/index.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { PlaywrightTestConfig } from '@playwright/test';
|
|
2
|
-
|
|
3
|
-
export interface BuildPlaywrightBaseConfigParams {
|
|
4
|
-
appPort: number;
|
|
5
|
-
appUrl: string;
|
|
6
|
-
ci?: boolean;
|
|
7
|
-
devices: typeof import('@playwright/test').devices;
|
|
8
|
-
webServerCommand: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Build a base Playwright config object with Regardio defaults.
|
|
13
|
-
* Consumers should wrap with defineConfig() in their local playwright.config.ts
|
|
14
|
-
*/
|
|
15
|
-
export function buildPlaywrightBaseConfig({
|
|
16
|
-
appUrl,
|
|
17
|
-
appPort,
|
|
18
|
-
devices,
|
|
19
|
-
ci = !!process.env.CI,
|
|
20
|
-
webServerCommand,
|
|
21
|
-
}: BuildPlaywrightBaseConfigParams): PlaywrightTestConfig {
|
|
22
|
-
if (!appUrl || typeof appUrl !== 'string') {
|
|
23
|
-
throw new Error('[playwright] appUrl must be a non-empty string');
|
|
24
|
-
}
|
|
25
|
-
if (!appPort || typeof appPort !== 'number') {
|
|
26
|
-
throw new Error('[playwright] appPort must be a number');
|
|
27
|
-
}
|
|
28
|
-
if (!devices) {
|
|
29
|
-
throw new Error('[playwright] devices must be provided from "@playwright/test"');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
forbidOnly: ci,
|
|
34
|
-
fullyParallel: true,
|
|
35
|
-
outputDir: './tests/test-results',
|
|
36
|
-
projects: [
|
|
37
|
-
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
|
38
|
-
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
|
|
39
|
-
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
|
|
40
|
-
{
|
|
41
|
-
name: 'iPad Pro 11 landscape',
|
|
42
|
-
use: { ...devices['iPad Pro 11 landscape'] },
|
|
43
|
-
},
|
|
44
|
-
{ name: 'iPhone 14 portrait', use: { ...devices['iPhone 14'] } },
|
|
45
|
-
{ name: 'Pixel 7 portrait', use: { ...devices['Pixel 7'] } },
|
|
46
|
-
],
|
|
47
|
-
reporter: [['html', { open: 'never', outputFolder: './tests/playwright-report' }]],
|
|
48
|
-
retries: ci ? 2 : 0,
|
|
49
|
-
testDir: './tests',
|
|
50
|
-
testMatch: '**/*.e2e.ts',
|
|
51
|
-
use: {
|
|
52
|
-
baseURL: appUrl,
|
|
53
|
-
trace: 'on-first-retry',
|
|
54
|
-
},
|
|
55
|
-
webServer: {
|
|
56
|
-
command: webServerCommand,
|
|
57
|
-
ignoreHTTPSErrors: true,
|
|
58
|
-
reuseExistingServer: !ci,
|
|
59
|
-
url: appUrl,
|
|
60
|
-
},
|
|
61
|
-
...(ci ? { workers: 1 } : {}),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# Regardio Release Workflow
|
|
2
|
-
# Copy this file to .github/workflows/release.yml in your package
|
|
3
|
-
#
|
|
4
|
-
# Required setup:
|
|
5
|
-
# 1. Add "ship:staging": "ship-staging", "ship:production": "ship-production" to package.json scripts
|
|
6
|
-
# 2. Create staging and production branches:
|
|
7
|
-
# git checkout -b staging && git push -u origin staging
|
|
8
|
-
# git checkout -b production && git push -u origin production
|
|
9
|
-
# 3. First npm publish must be done locally:
|
|
10
|
-
# pnpm build && npm publish --access public
|
|
11
|
-
#
|
|
12
|
-
# Usage:
|
|
13
|
-
# - Run `pnpm ship:staging "message"` to deploy changes to staging
|
|
14
|
-
# - Run `pnpm ship:production patch|minor|major` to version, promote to production, and trigger this workflow
|
|
15
|
-
|
|
16
|
-
name: Release
|
|
17
|
-
|
|
18
|
-
on:
|
|
19
|
-
push:
|
|
20
|
-
branches:
|
|
21
|
-
- production
|
|
22
|
-
|
|
23
|
-
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
24
|
-
|
|
25
|
-
jobs:
|
|
26
|
-
release:
|
|
27
|
-
name: Release
|
|
28
|
-
runs-on: ubuntu-latest
|
|
29
|
-
permissions:
|
|
30
|
-
contents: write
|
|
31
|
-
id-token: write
|
|
32
|
-
steps:
|
|
33
|
-
- name: Checkout
|
|
34
|
-
uses: actions/checkout@v6
|
|
35
|
-
|
|
36
|
-
- name: Setup pnpm
|
|
37
|
-
uses: pnpm/action-setup@v5
|
|
38
|
-
with:
|
|
39
|
-
version: 10
|
|
40
|
-
|
|
41
|
-
- name: Setup Node.js
|
|
42
|
-
uses: actions/setup-node@v6
|
|
43
|
-
with:
|
|
44
|
-
node-version: 24
|
|
45
|
-
registry-url: https://registry.npmjs.org
|
|
46
|
-
|
|
47
|
-
- name: Update npm for OIDC support
|
|
48
|
-
run: npm install -g npm@latest
|
|
49
|
-
|
|
50
|
-
- name: Replace workspace dependencies with npm versions
|
|
51
|
-
run: |
|
|
52
|
-
node -e "
|
|
53
|
-
const fs = require('fs');
|
|
54
|
-
const { execSync } = require('child_process');
|
|
55
|
-
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
56
|
-
['dependencies', 'devDependencies'].forEach(depType => {
|
|
57
|
-
if (pkg[depType]) {
|
|
58
|
-
Object.keys(pkg[depType]).forEach(key => {
|
|
59
|
-
if (pkg[depType][key].startsWith('workspace:')) {
|
|
60
|
-
try {
|
|
61
|
-
const version = execSync(`npm view ${key} version`, { encoding: 'utf8' }).trim();
|
|
62
|
-
pkg[depType][key] = version;
|
|
63
|
-
console.log(`Replaced ${key}@workspace:* with ${version}`);
|
|
64
|
-
} catch (e) {
|
|
65
|
-
console.error(`Error: Could not find ${key} on npm. Publish it first.`);
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
- name: Install dependencies
|
|
76
|
-
run: pnpm install --no-frozen-lockfile
|
|
77
|
-
|
|
78
|
-
- name: Build
|
|
79
|
-
run: pnpm build
|
|
80
|
-
|
|
81
|
-
- name: Publish to npm
|
|
82
|
-
id: publish
|
|
83
|
-
env:
|
|
84
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
85
|
-
run: |
|
|
86
|
-
IS_PRIVATE=$(node -p "require('./package.json').private ?? false")
|
|
87
|
-
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
88
|
-
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
|
89
|
-
echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
|
|
90
|
-
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
91
|
-
if [ "$IS_PRIVATE" = "true" ]; then
|
|
92
|
-
echo "Package $PACKAGE_NAME is private, skipping npm publish"
|
|
93
|
-
echo "published=false" >> $GITHUB_OUTPUT
|
|
94
|
-
else
|
|
95
|
-
PUBLISHED_VERSION=$(npm view "$PACKAGE_NAME" version 2>/dev/null || echo 'NOT_FOUND')
|
|
96
|
-
if [ "$PUBLISHED_VERSION" = "NOT_FOUND" ]; then
|
|
97
|
-
echo "::error::Package $PACKAGE_NAME not found on npm. First publish must be done locally."
|
|
98
|
-
echo "::error::Run: pnpm build && npm publish --access public"
|
|
99
|
-
exit 1
|
|
100
|
-
elif [ "$PUBLISHED_VERSION" != "$CURRENT_VERSION" ]; then
|
|
101
|
-
echo "Publishing $PACKAGE_NAME@$CURRENT_VERSION (npm has $PUBLISHED_VERSION)"
|
|
102
|
-
npm publish --access public --provenance
|
|
103
|
-
echo "published=true" >> $GITHUB_OUTPUT
|
|
104
|
-
else
|
|
105
|
-
echo "Version $CURRENT_VERSION already published, skipping"
|
|
106
|
-
echo "published=false" >> $GITHUB_OUTPUT
|
|
107
|
-
fi
|
|
108
|
-
fi
|
|
109
|
-
|
|
110
|
-
- name: Extract changelog entry
|
|
111
|
-
if: steps.publish.outputs.published == 'true'
|
|
112
|
-
id: changelog
|
|
113
|
-
run: |
|
|
114
|
-
# Extract the top section of CHANGELOG.md (from first ## heading to the next one)
|
|
115
|
-
ENTRY=$(awk '/^## /{found++} found==1{print} found==2{exit}' CHANGELOG.md)
|
|
116
|
-
echo "entry<<EOF" >> $GITHUB_OUTPUT
|
|
117
|
-
echo "$ENTRY" >> $GITHUB_OUTPUT
|
|
118
|
-
echo "EOF" >> $GITHUB_OUTPUT
|
|
119
|
-
|
|
120
|
-
- name: Create GitHub Release
|
|
121
|
-
if: steps.publish.outputs.published == 'true'
|
|
122
|
-
uses: softprops/action-gh-release@v2
|
|
123
|
-
with:
|
|
124
|
-
tag_name: v${{ steps.publish.outputs.current_version }}
|
|
125
|
-
name: v${{ steps.publish.outputs.current_version }}
|
|
126
|
-
body: ${{ steps.changelog.outputs.entry }}
|
|
127
|
-
env:
|
|
128
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test setup file for React packages using Vitest and Testing Library.
|
|
3
|
-
* Import this in your vitest.config.ts setupFiles array.
|
|
4
|
-
*
|
|
5
|
-
* Usage in vitest.config.ts:
|
|
6
|
-
* setupFiles: ['@regardio/dev/testing/setup-react']
|
|
7
|
-
*/
|
|
8
|
-
import '@testing-library/jest-dom/vitest';
|
package/src/vitest/node.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Coverage thresholds for library packages.
|
|
3
|
-
* These ensure adequate test coverage before publishing.
|
|
4
|
-
*/
|
|
5
|
-
export const coverageThresholds = {
|
|
6
|
-
branches: 80,
|
|
7
|
-
functions: 80,
|
|
8
|
-
lines: 80,
|
|
9
|
-
statements: 80,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Base Vitest configuration for Node.js packages.
|
|
14
|
-
* Use with defineConfig() in your vitest.config.ts
|
|
15
|
-
*/
|
|
16
|
-
export const vitestNodeConfig = {
|
|
17
|
-
coverage: {
|
|
18
|
-
provider: 'v8' as const,
|
|
19
|
-
thresholds: coverageThresholds,
|
|
20
|
-
},
|
|
21
|
-
environment: 'node',
|
|
22
|
-
exclude: ['node_modules', 'dist', 'build', '.turbo', '.react-router'],
|
|
23
|
-
globals: true,
|
|
24
|
-
include: ['**/*.test.ts', '**/*.test.tsx'],
|
|
25
|
-
};
|
package/src/vitest/react.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { coverageThresholds } from './node';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Vitest configuration for React packages with jsdom environment.
|
|
5
|
-
* Use with defineConfig() in your vitest.config.ts
|
|
6
|
-
*
|
|
7
|
-
* Requires a setup file that imports '@testing-library/jest-dom/vitest'
|
|
8
|
-
*/
|
|
9
|
-
export const vitestReactConfig = {
|
|
10
|
-
coverage: {
|
|
11
|
-
provider: 'v8' as const,
|
|
12
|
-
thresholds: coverageThresholds,
|
|
13
|
-
},
|
|
14
|
-
environment: 'jsdom',
|
|
15
|
-
exclude: ['node_modules', 'dist', 'build', '.turbo', '.react-router'],
|
|
16
|
-
globals: true,
|
|
17
|
-
include: ['**/*.test.ts', '**/*.test.tsx'],
|
|
18
|
-
setupFiles: ['./src/test-setup.ts'],
|
|
19
|
-
};
|
|
File without changes
|