@epic-web/workshop-utils 6.16.8 → 6.17.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.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,UAY7C;AAED,wBAAgB,uBAAuB,CAAC,EACvC,UAAU,EACV,UAAU,GACV,EAAE;IACF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;;;EAYA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,UAY7C;AAED,wBAAgB,uBAAuB,CAAC,EACvC,UAAU,EACV,UAAU,GACV,EAAE;IACF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;;;EAaA"}
package/dist/esm/utils.js CHANGED
@@ -13,7 +13,8 @@ export function getErrorMessage(error) {
13
13
  }
14
14
  export function handleGitHubRepoAndRoot({ githubRepo, githubRoot, }) {
15
15
  if (githubRepo) {
16
- githubRoot = `${githubRepo.replace(/\/$/, '')}/tree/main`;
16
+ githubRepo = githubRepo.replace(/\/$/, '');
17
+ githubRoot = `${githubRepo}/tree/main`;
17
18
  }
18
19
  else if (githubRoot) {
19
20
  githubRepo = githubRoot.replace(/\/(blob|tree)\/.*$/, '');
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,MAAM,UAAU,eAAe,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,IACC,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAChC,CAAC;QACF,OAAO,KAAK,CAAC,OAAO,CAAA;IACrB,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAA;IAC7D,OAAO,eAAe,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EACvC,UAAU,EACV,UAAU,GAIV;IACA,IAAI,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAA;IAC1D,CAAC;SAAM,IAAI,UAAU,EAAE,CAAC;QACvB,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;QACzD,UAAU,GAAG,GAAG,UAAU,YAAY,CAAA;IACvC,CAAC;SAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACd,sJAAsJ,CACtJ,CAAA;IACF,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAA;AAClC,CAAC","sourcesContent":["import './init-env.js'\n\nexport function getErrorMessage(error: unknown) {\n\tif (typeof error === 'string') return error\n\tif (\n\t\terror &&\n\t\ttypeof error === 'object' &&\n\t\t'message' in error &&\n\t\ttypeof error.message === 'string'\n\t) {\n\t\treturn error.message\n\t}\n\tconsole.error('Unable to get error message for error', error)\n\treturn 'Unknown Error'\n}\n\nexport function handleGitHubRepoAndRoot({\n\tgithubRepo,\n\tgithubRoot,\n}: {\n\tgithubRepo?: string\n\tgithubRoot?: string\n}) {\n\tif (githubRepo) {\n\t\tgithubRoot = `${githubRepo.replace(/\\/$/, '')}/tree/main`\n\t} else if (githubRoot) {\n\t\tgithubRepo = githubRoot.replace(/\\/(blob|tree)\\/.*$/, '')\n\t\tgithubRoot = `${githubRepo}/tree/main`\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Either githubRepo or githubRoot is required. Please ensure your epicshop package.json config includes either githubRepo or githubRoot configuration.`,\n\t\t)\n\t}\n\treturn { githubRepo, githubRoot }\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,MAAM,UAAU,eAAe,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,IACC,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAChC,CAAC;QACF,OAAO,KAAK,CAAC,OAAO,CAAA;IACrB,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAA;IAC7D,OAAO,eAAe,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EACvC,UAAU,EACV,UAAU,GAIV;IACA,IAAI,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAC1C,UAAU,GAAG,GAAG,UAAU,YAAY,CAAA;IACvC,CAAC;SAAM,IAAI,UAAU,EAAE,CAAC;QACvB,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;QACzD,UAAU,GAAG,GAAG,UAAU,YAAY,CAAA;IACvC,CAAC;SAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACd,sJAAsJ,CACtJ,CAAA;IACF,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAA;AAClC,CAAC","sourcesContent":["import './init-env.js'\n\nexport function getErrorMessage(error: unknown) {\n\tif (typeof error === 'string') return error\n\tif (\n\t\terror &&\n\t\ttypeof error === 'object' &&\n\t\t'message' in error &&\n\t\ttypeof error.message === 'string'\n\t) {\n\t\treturn error.message\n\t}\n\tconsole.error('Unable to get error message for error', error)\n\treturn 'Unknown Error'\n}\n\nexport function handleGitHubRepoAndRoot({\n\tgithubRepo,\n\tgithubRoot,\n}: {\n\tgithubRepo?: string\n\tgithubRoot?: string\n}) {\n\tif (githubRepo) {\n\t\tgithubRepo = githubRepo.replace(/\\/$/, '')\n\t\tgithubRoot = `${githubRepo}/tree/main`\n\t} else if (githubRoot) {\n\t\tgithubRepo = githubRoot.replace(/\\/(blob|tree)\\/.*$/, '')\n\t\tgithubRoot = `${githubRepo}/tree/main`\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Either githubRepo or githubRoot is required. Please ensure your epicshop package.json config includes either githubRepo or githubRoot configuration.`,\n\t\t)\n\t}\n\treturn { githubRepo, githubRoot }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/utils.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,139 @@
1
+ import { test, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ import { getErrorMessage, handleGitHubRepoAndRoot } from './utils.js';
3
+ // Setup console.error mocking for all tests
4
+ beforeEach(() => {
5
+ vi.spyOn(console, 'error').mockImplementation(() => { });
6
+ });
7
+ afterEach(() => {
8
+ vi.restoreAllMocks();
9
+ });
10
+ test('getErrorMessage should return string errors as-is', () => {
11
+ const error = 'Something went wrong';
12
+ expect(getErrorMessage(error)).toBe('Something went wrong');
13
+ });
14
+ test('getErrorMessage should extract message from Error objects', () => {
15
+ const error = new Error('Database connection failed');
16
+ expect(getErrorMessage(error)).toBe('Database connection failed');
17
+ });
18
+ test('getErrorMessage should extract message from objects with message property', () => {
19
+ const error = { message: 'Custom error message' };
20
+ expect(getErrorMessage(error)).toBe('Custom error message');
21
+ });
22
+ test('getErrorMessage should handle objects with non-string message property', () => {
23
+ const error = { message: 123 };
24
+ const consoleSpy = vi.spyOn(console, 'error');
25
+ expect(getErrorMessage(error)).toBe('Unknown Error');
26
+ expect(consoleSpy).toHaveBeenCalledWith('Unable to get error message for error', error);
27
+ });
28
+ test('getErrorMessage should handle objects without message property', () => {
29
+ const error = { code: 500, status: 'error' };
30
+ const consoleSpy = vi.spyOn(console, 'error');
31
+ expect(getErrorMessage(error)).toBe('Unknown Error');
32
+ expect(consoleSpy).toHaveBeenCalledWith('Unable to get error message for error', error);
33
+ });
34
+ test('getErrorMessage should handle null errors', () => {
35
+ const consoleSpy = vi.spyOn(console, 'error');
36
+ expect(getErrorMessage(null)).toBe('Unknown Error');
37
+ expect(consoleSpy).toHaveBeenCalledWith('Unable to get error message for error', null);
38
+ });
39
+ test('getErrorMessage should handle undefined errors', () => {
40
+ const consoleSpy = vi.spyOn(console, 'error');
41
+ expect(getErrorMessage(undefined)).toBe('Unknown Error');
42
+ expect(consoleSpy).toHaveBeenCalledWith('Unable to get error message for error', undefined);
43
+ });
44
+ test('getErrorMessage should handle primitive non-string errors', () => {
45
+ const consoleSpy = vi.spyOn(console, 'error');
46
+ expect(getErrorMessage(123)).toBe('Unknown Error');
47
+ expect(consoleSpy).toHaveBeenCalledWith('Unable to get error message for error', 123);
48
+ expect(getErrorMessage(true)).toBe('Unknown Error');
49
+ expect(consoleSpy).toHaveBeenCalledWith('Unable to get error message for error', true);
50
+ });
51
+ test('getErrorMessage should handle empty objects', () => {
52
+ const error = {};
53
+ const consoleSpy = vi.spyOn(console, 'error');
54
+ expect(getErrorMessage(error)).toBe('Unknown Error');
55
+ expect(consoleSpy).toHaveBeenCalledWith('Unable to get error message for error', error);
56
+ });
57
+ test('handleGitHubRepoAndRoot should handle githubRepo with trailing slash', () => {
58
+ const result = handleGitHubRepoAndRoot({
59
+ githubRepo: 'https://github.com/user/repo/',
60
+ });
61
+ expect(result).toEqual({
62
+ githubRepo: 'https://github.com/user/repo',
63
+ githubRoot: 'https://github.com/user/repo/tree/main',
64
+ });
65
+ });
66
+ test('handleGitHubRepoAndRoot should handle githubRepo without trailing slash', () => {
67
+ const result = handleGitHubRepoAndRoot({
68
+ githubRepo: 'https://github.com/user/repo',
69
+ });
70
+ expect(result).toEqual({
71
+ githubRepo: 'https://github.com/user/repo',
72
+ githubRoot: 'https://github.com/user/repo/tree/main',
73
+ });
74
+ });
75
+ test('handleGitHubRepoAndRoot should handle githubRoot with blob path', () => {
76
+ const result = handleGitHubRepoAndRoot({
77
+ githubRoot: 'https://github.com/user/repo/blob/main/src/file.ts',
78
+ });
79
+ expect(result).toEqual({
80
+ githubRepo: 'https://github.com/user/repo',
81
+ githubRoot: 'https://github.com/user/repo/tree/main',
82
+ });
83
+ });
84
+ test('handleGitHubRepoAndRoot should handle githubRoot with tree path', () => {
85
+ const result = handleGitHubRepoAndRoot({
86
+ githubRoot: 'https://github.com/user/repo/tree/develop/src',
87
+ });
88
+ expect(result).toEqual({
89
+ githubRepo: 'https://github.com/user/repo',
90
+ githubRoot: 'https://github.com/user/repo/tree/main',
91
+ });
92
+ });
93
+ test('handleGitHubRepoAndRoot should handle githubRoot without path', () => {
94
+ const result = handleGitHubRepoAndRoot({
95
+ githubRoot: 'https://github.com/user/repo',
96
+ });
97
+ expect(result).toEqual({
98
+ githubRepo: 'https://github.com/user/repo',
99
+ githubRoot: 'https://github.com/user/repo/tree/main',
100
+ });
101
+ });
102
+ test('handleGitHubRepoAndRoot should prioritize githubRepo over githubRoot when both provided', () => {
103
+ const result = handleGitHubRepoAndRoot({
104
+ githubRepo: 'https://github.com/user/repo',
105
+ githubRoot: 'https://github.com/other/repo/blob/main/src/file.ts',
106
+ });
107
+ expect(result).toEqual({
108
+ githubRepo: 'https://github.com/user/repo',
109
+ githubRoot: 'https://github.com/user/repo/tree/main',
110
+ });
111
+ });
112
+ test('handleGitHubRepoAndRoot should throw error when neither githubRepo nor githubRoot provided', () => {
113
+ expect(() => handleGitHubRepoAndRoot({})).toThrow('Either githubRepo or githubRoot is required. Please ensure your epicshop package.json config includes either githubRepo or githubRoot configuration.');
114
+ });
115
+ test('handleGitHubRepoAndRoot should throw error when both githubRepo and githubRoot are undefined', () => {
116
+ expect(() => handleGitHubRepoAndRoot({
117
+ githubRepo: undefined,
118
+ githubRoot: undefined,
119
+ })).toThrow('Either githubRepo or githubRoot is required. Please ensure your epicshop package.json config includes either githubRepo or githubRoot configuration.');
120
+ });
121
+ test('handleGitHubRepoAndRoot should handle githubRoot with complex blob path', () => {
122
+ const result = handleGitHubRepoAndRoot({
123
+ githubRoot: 'https://github.com/user/repo/blob/feature-branch/packages/app/src/components/button.tsx',
124
+ });
125
+ expect(result).toEqual({
126
+ githubRepo: 'https://github.com/user/repo',
127
+ githubRoot: 'https://github.com/user/repo/tree/main',
128
+ });
129
+ });
130
+ test('handleGitHubRepoAndRoot should handle githubRoot with complex tree path', () => {
131
+ const result = handleGitHubRepoAndRoot({
132
+ githubRoot: 'https://github.com/user/repo/tree/develop/packages/workshop/src/utils.ts',
133
+ });
134
+ expect(result).toEqual({
135
+ githubRepo: 'https://github.com/user/repo',
136
+ githubRoot: 'https://github.com/user/repo/tree/main',
137
+ });
138
+ });
139
+ //# sourceMappingURL=utils.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../src/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAErE,4CAA4C;AAC5C,UAAU,CAAC,GAAG,EAAE;IACf,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;AACxD,CAAC,CAAC,CAAA;AAEF,SAAS,CAAC,GAAG,EAAE;IACd,EAAE,CAAC,e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tJ,CAAA;AACF,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,yEAAyE,EAAE,GAAG,EAAE;IACpF,MAAM,MAAM,GAAG,uBAAuB,CAAC;QACtC,UAAU,EACT,yFAAyF;KAC1F,CAAC,CAAA;IAEF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;QACtB,UAAU,EAAE,8BAA8B;QAC1C,UAAU,EAAE,wCAAwC;KACpD,CAAC,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,yEAAyE,EAAE,GAAG,EAAE;IACpF,MAAM,MAAM,GAAG,uBAAuB,CAAC;QACtC,UAAU,EACT,0EAA0E;KAC3E,CAAC,CAAA;IAEF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;QACtB,UAAU,EAAE,8BAA8B;QAC1C,UAAU,EAAE,wCAAwC;KACpD,CAAC,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { test, expect, vi, beforeEach, afterEach } from 'vitest'\nimport { getErrorMessage, handleGitHubRepoAndRoot } from './utils.js'\n\n// Setup console.error mocking for all tests\nbeforeEach(() => {\n\tvi.spyOn(console, 'error').mockImplementation(() => {})\n})\n\nafterEach(() => {\n\tvi.restoreAllMocks()\n})\n\ntest('getErrorMessage should return string errors as-is', () => {\n\tconst error = 'Something went wrong'\n\texpect(getErrorMessage(error)).toBe('Something went wrong')\n})\n\ntest('getErrorMessage should extract message from Error objects', () => {\n\tconst error = new Error('Database connection failed')\n\texpect(getErrorMessage(error)).toBe('Database connection failed')\n})\n\ntest('getErrorMessage should extract message from objects with message property', () => {\n\tconst error = { message: 'Custom error message' }\n\texpect(getErrorMessage(error)).toBe('Custom error message')\n})\n\ntest('getErrorMessage should handle objects with non-string message property', () => {\n\tconst error = { message: 123 }\n\tconst consoleSpy = vi.spyOn(console, 'error')\n\n\texpect(getErrorMessage(error)).toBe('Unknown Error')\n\texpect(consoleSpy).toHaveBeenCalledWith(\n\t\t'Unable to get error message for error',\n\t\terror,\n\t)\n})\n\ntest('getErrorMessage should handle objects without message property', () => {\n\tconst error = { code: 500, status: 'error' }\n\tconst consoleSpy = vi.spyOn(console, 'error')\n\n\texpect(getErrorMessage(error)).toBe('Unknown Error')\n\texpect(consoleSpy).toHaveBeenCalledWith(\n\t\t'Unable to get error message for error',\n\t\terror,\n\t)\n})\n\ntest('getErrorMessage should handle null errors', () => {\n\tconst consoleSpy = vi.spyOn(console, 'error')\n\n\texpect(getErrorMessage(null)).toBe('Unknown Error')\n\texpect(consoleSpy).toHaveBeenCalledWith(\n\t\t'Unable to get error message for error',\n\t\tnull,\n\t)\n})\n\ntest('getErrorMessage should handle undefined errors', () => {\n\tconst consoleSpy = vi.spyOn(console, 'error')\n\n\texpect(getErrorMessage(undefined)).toBe('Unknown Error')\n\texpect(consoleSpy).toHaveBeenCalledWith(\n\t\t'Unable to get error message for error',\n\t\tundefined,\n\t)\n})\n\ntest('getErrorMessage should handle primitive non-string errors', () => {\n\tconst consoleSpy = vi.spyOn(console, 'error')\n\n\texpect(getErrorMessage(123)).toBe('Unknown Error')\n\texpect(consoleSpy).toHaveBeenCalledWith(\n\t\t'Unable to get error message for error',\n\t\t123,\n\t)\n\n\texpect(getErrorMessage(true)).toBe('Unknown Error')\n\texpect(consoleSpy).toHaveBeenCalledWith(\n\t\t'Unable to get error message for error',\n\t\ttrue,\n\t)\n})\n\ntest('getErrorMessage should handle empty objects', () => {\n\tconst error = {}\n\tconst consoleSpy = vi.spyOn(console, 'error')\n\n\texpect(getErrorMessage(error)).toBe('Unknown Error')\n\texpect(consoleSpy).toHaveBeenCalledWith(\n\t\t'Unable to get error message for error',\n\t\terror,\n\t)\n})\n\ntest('handleGitHubRepoAndRoot should handle githubRepo with trailing slash', () => {\n\tconst result = handleGitHubRepoAndRoot({\n\t\tgithubRepo: 'https://github.com/user/repo/',\n\t})\n\n\texpect(result).toEqual({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/user/repo/tree/main',\n\t})\n})\n\ntest('handleGitHubRepoAndRoot should handle githubRepo without trailing slash', () => {\n\tconst result = handleGitHubRepoAndRoot({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t})\n\n\texpect(result).toEqual({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/user/repo/tree/main',\n\t})\n})\n\ntest('handleGitHubRepoAndRoot should handle githubRoot with blob path', () => {\n\tconst result = handleGitHubRepoAndRoot({\n\t\tgithubRoot: 'https://github.com/user/repo/blob/main/src/file.ts',\n\t})\n\n\texpect(result).toEqual({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/user/repo/tree/main',\n\t})\n})\n\ntest('handleGitHubRepoAndRoot should handle githubRoot with tree path', () => {\n\tconst result = handleGitHubRepoAndRoot({\n\t\tgithubRoot: 'https://github.com/user/repo/tree/develop/src',\n\t})\n\n\texpect(result).toEqual({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/user/repo/tree/main',\n\t})\n})\n\ntest('handleGitHubRepoAndRoot should handle githubRoot without path', () => {\n\tconst result = handleGitHubRepoAndRoot({\n\t\tgithubRoot: 'https://github.com/user/repo',\n\t})\n\n\texpect(result).toEqual({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/user/repo/tree/main',\n\t})\n})\n\ntest('handleGitHubRepoAndRoot should prioritize githubRepo over githubRoot when both provided', () => {\n\tconst result = handleGitHubRepoAndRoot({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/other/repo/blob/main/src/file.ts',\n\t})\n\n\texpect(result).toEqual({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/user/repo/tree/main',\n\t})\n})\n\ntest('handleGitHubRepoAndRoot should throw error when neither githubRepo nor githubRoot provided', () => {\n\texpect(() => handleGitHubRepoAndRoot({})).toThrow(\n\t\t'Either githubRepo or githubRoot is required. Please ensure your epicshop package.json config includes either githubRepo or githubRoot configuration.',\n\t)\n})\n\ntest('handleGitHubRepoAndRoot should throw error when both githubRepo and githubRoot are undefined', () => {\n\texpect(() =>\n\t\thandleGitHubRepoAndRoot({\n\t\t\tgithubRepo: undefined,\n\t\t\tgithubRoot: undefined,\n\t\t}),\n\t).toThrow(\n\t\t'Either githubRepo or githubRoot is required. Please ensure your epicshop package.json config includes either githubRepo or githubRoot configuration.',\n\t)\n})\n\ntest('handleGitHubRepoAndRoot should handle githubRoot with complex blob path', () => {\n\tconst result = handleGitHubRepoAndRoot({\n\t\tgithubRoot:\n\t\t\t'https://github.com/user/repo/blob/feature-branch/packages/app/src/components/button.tsx',\n\t})\n\n\texpect(result).toEqual({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/user/repo/tree/main',\n\t})\n})\n\ntest('handleGitHubRepoAndRoot should handle githubRoot with complex tree path', () => {\n\tconst result = handleGitHubRepoAndRoot({\n\t\tgithubRoot:\n\t\t\t'https://github.com/user/repo/tree/develop/packages/workshop/src/utils.ts',\n\t})\n\n\texpect(result).toEqual({\n\t\tgithubRepo: 'https://github.com/user/repo',\n\t\tgithubRoot: 'https://github.com/user/repo/tree/main',\n\t})\n})\n"]}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@epic-web/workshop-utils","version":"6.16.8","publishConfig":{"access":"public"},"type":"module","tshy":{"project":"./tsconfig.build.json","dialects":["esm"],"exports":{"./package.json":"./package.json","./apps.server":"./src/apps.server.ts","./diff.server":"./src/diff.server.ts","./env.server":"./src/env.server.ts","./epic-api.server":"./src/epic-api.server.ts","./user.server":"./src/user.server.ts","./cache.server":"./src/cache.server.ts","./config.server":"./src/config.server.ts","./db.server":"./src/db.server.ts","./timing.server":"./src/timing.server.ts","./modified-time.server":"./src/modified-time.server.ts","./compile-mdx.server":"./src/compile-mdx.server.ts","./git.server":"./src/git.server.ts","./iframe-sync":"./src/iframe-sync.ts","./init-env":"./src/init-env.ts","./playwright.server":"./src/playwright.server.ts","./notifications.server":"./src/notifications.server.ts","./process-manager.server":"./src/process-manager.server.ts","./test":"./src/test.ts","./request-context.server":"./src/request-context.server.ts","./utils.server":"./src/utils.server.ts","./utils":"./src/utils.ts"}},"exports":{"./package.json":"./package.json","./apps.server":{"import":{"types":"./dist/esm/apps.server.d.ts","default":"./dist/esm/apps.server.js"}},"./diff.server":{"import":{"types":"./dist/esm/diff.server.d.ts","default":"./dist/esm/diff.server.js"}},"./env.server":{"import":{"types":"./dist/esm/env.server.d.ts","default":"./dist/esm/env.server.js"}},"./epic-api.server":{"import":{"types":"./dist/esm/epic-api.server.d.ts","default":"./dist/esm/epic-api.server.js"}},"./user.server":{"import":{"types":"./dist/esm/user.server.d.ts","default":"./dist/esm/user.server.js"}},"./cache.server":{"import":{"types":"./dist/esm/cache.server.d.ts","default":"./dist/esm/cache.server.js"}},"./config.server":{"import":{"types":"./dist/esm/config.server.d.ts","default":"./dist/esm/config.server.js"}},"./db.server":{"import":{"types":"./dist/esm/db.server.d.ts","default":"./dist/esm/db.server.js"}},"./timing.server":{"import":{"types":"./dist/esm/timing.server.d.ts","default":"./dist/esm/timing.server.js"}},"./modified-time.server":{"import":{"types":"./dist/esm/modified-time.server.d.ts","default":"./dist/esm/modified-time.server.js"}},"./compile-mdx.server":{"import":{"types":"./dist/esm/compile-mdx.server.d.ts","default":"./dist/esm/compile-mdx.server.js"}},"./git.server":{"import":{"types":"./dist/esm/git.server.d.ts","default":"./dist/esm/git.server.js"}},"./iframe-sync":{"import":{"types":"./dist/esm/iframe-sync.d.ts","default":"./dist/esm/iframe-sync.js"}},"./init-env":{"import":{"types":"./dist/esm/init-env.d.ts","default":"./dist/esm/init-env.js"}},"./playwright.server":{"import":{"types":"./dist/esm/playwright.server.d.ts","default":"./dist/esm/playwright.server.js"}},"./notifications.server":{"import":{"types":"./dist/esm/notifications.server.d.ts","default":"./dist/esm/notifications.server.js"}},"./process-manager.server":{"import":{"types":"./dist/esm/process-manager.server.d.ts","default":"./dist/esm/process-manager.server.js"}},"./test":{"import":{"types":"./dist/esm/test.d.ts","default":"./dist/esm/test.js"}},"./request-context.server":{"import":{"types":"./dist/esm/request-context.server.d.ts","default":"./dist/esm/request-context.server.js"}},"./utils.server":{"import":{"types":"./dist/esm/utils.server.d.ts","default":"./dist/esm/utils.server.js"}},"./utils":{"import":{"types":"./dist/esm/utils.d.ts","default":"./dist/esm/utils.js"}}},"files":["dist"],"scripts":{"typecheck":"tsc --noEmit","build":"tshy","build:watch":"nx watch --projects=@epic-web/workshop-utils -- nx run \\$NX_PROJECT_NAME:build"},"dependencies":{"@epic-web/cachified":"^5.6.0","@epic-web/invariant":"^1.0.0","@epic-web/remember":"^1.1.0","@kentcdodds/md-temp":"^10.0.1","@mdx-js/mdx":"^3.1.0","@paralleldrive/cuid2":"^2.2.2","@playwright/test":"^1.53.2","@react-router/node":"^7.6.3","@sentry/react-router":"^9.40.0","@testing-library/dom":"^10.4.0","@testing-library/jest-dom":"^6.6.3","@total-typescript/ts-reset":"^0.6.1","@types/chai":"^5.2.2","@types/chai-dom":"^1.11.3","@vitest/expect":"^3.2.4","chai":"^5.2.0","chai-dom":"^1.12.1","chalk":"^5.4.1","chokidar":"^4.0.3","close-with-grace":"^2.2.0","cookie":"^1.0.2","cross-spawn":"^7.0.6","dayjs":"^1.11.13","esbuild":"^0.25.5","execa":"^9.6.0","find-process":"^1.4.10","fkill":"^9.0.0","fs-extra":"^11.3.0","globby":"^14.1.0","ignore":"^7.0.5","json5":"^2.2.3","lru-cache":"^11.1.0","lz-string":"^1.5.0","md5-hex":"^5.0.0","mdast-util-mdx-jsx":"^3.2.0","mdx-bundler":"^10.1.1","p-queue":"^8.1.0","parse-git-diff":"^0.0.19","rehype":"^13.0.2","rehype-autolink-headings":"^7.1.0","remark":"^15.0.1","remark-emoji":"^5.0.1","remark-gfm":"^4.0.1","shiki":"^3.7.0","unified":"^11.0.5","unist-util-remove-position":"^5.0.0","unist-util-visit":"^5.0.0","zod":"^3.25.71"},"devDependencies":{"@types/hast":"^3.0.4","@types/mdast":"^4.0.4","@types/node":"^24.0.10","tshy":"^3.0.2"},"repository":{"type":"git","url":"https://github.com/epicweb-dev/epicshop.git","directory":"packages/workshop-utils"}}
1
+ {"name":"@epic-web/workshop-utils","version":"6.17.0","publishConfig":{"access":"public"},"type":"module","tshy":{"project":"./tsconfig.build.json","dialects":["esm"],"exports":{"./package.json":"./package.json","./apps.server":"./src/apps.server.ts","./diff.server":"./src/diff.server.ts","./env.server":"./src/env.server.ts","./epic-api.server":"./src/epic-api.server.ts","./user.server":"./src/user.server.ts","./cache.server":"./src/cache.server.ts","./config.server":"./src/config.server.ts","./db.server":"./src/db.server.ts","./timing.server":"./src/timing.server.ts","./modified-time.server":"./src/modified-time.server.ts","./compile-mdx.server":"./src/compile-mdx.server.ts","./git.server":"./src/git.server.ts","./iframe-sync":"./src/iframe-sync.ts","./init-env":"./src/init-env.ts","./playwright.server":"./src/playwright.server.ts","./notifications.server":"./src/notifications.server.ts","./process-manager.server":"./src/process-manager.server.ts","./test":"./src/test.ts","./request-context.server":"./src/request-context.server.ts","./utils.server":"./src/utils.server.ts","./utils":"./src/utils.ts"}},"exports":{"./package.json":"./package.json","./apps.server":{"import":{"types":"./dist/esm/apps.server.d.ts","default":"./dist/esm/apps.server.js"}},"./diff.server":{"import":{"types":"./dist/esm/diff.server.d.ts","default":"./dist/esm/diff.server.js"}},"./env.server":{"import":{"types":"./dist/esm/env.server.d.ts","default":"./dist/esm/env.server.js"}},"./epic-api.server":{"import":{"types":"./dist/esm/epic-api.server.d.ts","default":"./dist/esm/epic-api.server.js"}},"./user.server":{"import":{"types":"./dist/esm/user.server.d.ts","default":"./dist/esm/user.server.js"}},"./cache.server":{"import":{"types":"./dist/esm/cache.server.d.ts","default":"./dist/esm/cache.server.js"}},"./config.server":{"import":{"types":"./dist/esm/config.server.d.ts","default":"./dist/esm/config.server.js"}},"./db.server":{"import":{"types":"./dist/esm/db.server.d.ts","default":"./dist/esm/db.server.js"}},"./timing.server":{"import":{"types":"./dist/esm/timing.server.d.ts","default":"./dist/esm/timing.server.js"}},"./modified-time.server":{"import":{"types":"./dist/esm/modified-time.server.d.ts","default":"./dist/esm/modified-time.server.js"}},"./compile-mdx.server":{"import":{"types":"./dist/esm/compile-mdx.server.d.ts","default":"./dist/esm/compile-mdx.server.js"}},"./git.server":{"import":{"types":"./dist/esm/git.server.d.ts","default":"./dist/esm/git.server.js"}},"./iframe-sync":{"import":{"types":"./dist/esm/iframe-sync.d.ts","default":"./dist/esm/iframe-sync.js"}},"./init-env":{"import":{"types":"./dist/esm/init-env.d.ts","default":"./dist/esm/init-env.js"}},"./playwright.server":{"import":{"types":"./dist/esm/playwright.server.d.ts","default":"./dist/esm/playwright.server.js"}},"./notifications.server":{"import":{"types":"./dist/esm/notifications.server.d.ts","default":"./dist/esm/notifications.server.js"}},"./process-manager.server":{"import":{"types":"./dist/esm/process-manager.server.d.ts","default":"./dist/esm/process-manager.server.js"}},"./test":{"import":{"types":"./dist/esm/test.d.ts","default":"./dist/esm/test.js"}},"./request-context.server":{"import":{"types":"./dist/esm/request-context.server.d.ts","default":"./dist/esm/request-context.server.js"}},"./utils.server":{"import":{"types":"./dist/esm/utils.server.d.ts","default":"./dist/esm/utils.server.js"}},"./utils":{"import":{"types":"./dist/esm/utils.d.ts","default":"./dist/esm/utils.js"}}},"files":["dist"],"scripts":{"test":"vitest","typecheck":"tsc --noEmit","build":"tshy","build:watch":"nx watch --projects=@epic-web/workshop-utils -- nx run \\$NX_PROJECT_NAME:build"},"dependencies":{"@epic-web/cachified":"^5.6.0","@epic-web/invariant":"^1.0.0","@epic-web/remember":"^1.1.0","@kentcdodds/md-temp":"^10.0.1","@mdx-js/mdx":"^3.1.0","@paralleldrive/cuid2":"^2.2.2","@playwright/test":"^1.53.2","@react-router/node":"^7.6.3","@sentry/react-router":"^9.40.0","@testing-library/dom":"^10.4.0","@testing-library/jest-dom":"^6.6.3","@total-typescript/ts-reset":"^0.6.1","@types/chai":"^5.2.2","@types/chai-dom":"^1.11.3","@vitest/expect":"^3.2.4","chai":"^5.2.0","chai-dom":"^1.12.1","chalk":"^5.4.1","chokidar":"^4.0.3","close-with-grace":"^2.2.0","cookie":"^1.0.2","cross-spawn":"^7.0.6","dayjs":"^1.11.13","esbuild":"^0.25.5","execa":"^9.6.0","find-process":"^1.4.10","fkill":"^9.0.0","fs-extra":"^11.3.0","globby":"^14.1.0","ignore":"^7.0.5","json5":"^2.2.3","lru-cache":"^11.1.0","lz-string":"^1.5.0","md5-hex":"^5.0.0","mdast-util-mdx-jsx":"^3.2.0","mdx-bundler":"^10.1.1","p-queue":"^8.1.0","parse-git-diff":"^0.0.19","react-router":"^7.7.0","rehype":"^13.0.2","rehype-autolink-headings":"^7.1.0","remark":"^15.0.1","remark-emoji":"^5.0.1","remark-gfm":"^4.0.1","shiki":"^3.7.0","unified":"^11.0.5","unist-util-remove-position":"^5.0.0","unist-util-visit":"^5.0.0","zod":"^3.25.71"},"devDependencies":{"@types/hast":"^3.0.4","@types/mdast":"^4.0.4","@types/node":"^24.0.10","tshy":"^3.0.2","vitest":"^3.2.4"},"repository":{"type":"git","url":"https://github.com/epicweb-dev/epicshop.git","directory":"packages/workshop-utils"}}