@tanstack/cta-engine 0.15.1 → 0.15.2
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/dist/index.js +1 -1
- package/dist/registry.js +6 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/utils.js +14 -0
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/registry.ts +6 -4
- package/src/utils.ts +15 -0
- package/tests/utils.test.ts +26 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { DEFAULT_PACKAGE_MANAGER, SUPPORTED_PACKAGE_MANAGERS, getPackageManager,
|
|
|
9
9
|
export { registerFramework, getFrameworkById, getFrameworkByName, getFrameworks, } from './frameworks.js';
|
|
10
10
|
export { writeConfigFileToEnvironment, readConfigFileFromEnvironment, readConfigFile, } from './config-file.js';
|
|
11
11
|
export { cleanUpFiles, cleanUpFileArray, readFileHelper, getBinaryFile, recursivelyGatherFiles, relativePath, } from './file-helpers.js';
|
|
12
|
-
export { formatCommand } from './utils.js';
|
|
12
|
+
export { formatCommand, handleSpecialURL } from './utils.js';
|
|
13
13
|
export { initStarter, compileStarter } from './custom-add-ons/starter.js';
|
|
14
14
|
export { initAddOn, compileAddOn } from './custom-add-ons/add-on.js';
|
|
15
15
|
export { createAppOptionsFromPersisted, createSerializedOptionsFromPersisted, } from './custom-add-ons/shared.js';
|
package/dist/registry.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { loadRemoteAddOn } from './custom-add-ons/add-on.js';
|
|
3
3
|
import { loadStarter } from './custom-add-ons/starter.js';
|
|
4
|
+
import { handleSpecialURL } from './utils.js';
|
|
4
5
|
const registrySchema = z.object({
|
|
5
6
|
starters: z
|
|
6
7
|
.array(z.object({
|
|
@@ -32,15 +33,16 @@ function absolutizeUrl(originalUrl, relativeUrl) {
|
|
|
32
33
|
export async function getRawRegistry(registryUrl) {
|
|
33
34
|
const regUrl = registryUrl || process.env.CTA_REGISTRY;
|
|
34
35
|
if (regUrl) {
|
|
35
|
-
const
|
|
36
|
+
const url = handleSpecialURL(regUrl);
|
|
37
|
+
const registry = (await fetch(url).then((res) => res.json()));
|
|
36
38
|
const parsedRegistry = registrySchema.parse(registry);
|
|
37
39
|
for (const addOn of parsedRegistry['add-ons'] || []) {
|
|
38
|
-
addOn.url = absolutizeUrl(
|
|
40
|
+
addOn.url = absolutizeUrl(url, addOn.url);
|
|
39
41
|
}
|
|
40
42
|
for (const starter of parsedRegistry.starters || []) {
|
|
41
|
-
starter.url = absolutizeUrl(
|
|
43
|
+
starter.url = absolutizeUrl(url, starter.url);
|
|
42
44
|
if (starter.banner) {
|
|
43
|
-
starter.banner = absolutizeUrl(
|
|
45
|
+
starter.banner = absolutizeUrl(url, starter.banner);
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
return parsedRegistry;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { DEFAULT_PACKAGE_MANAGER, SUPPORTED_PACKAGE_MANAGERS, getPackageManager,
|
|
|
9
9
|
export { registerFramework, getFrameworkById, getFrameworkByName, getFrameworks, } from './frameworks.js';
|
|
10
10
|
export { writeConfigFileToEnvironment, readConfigFileFromEnvironment, readConfigFile, } from './config-file.js';
|
|
11
11
|
export { cleanUpFiles, cleanUpFileArray, readFileHelper, getBinaryFile, recursivelyGatherFiles, relativePath, } from './file-helpers.js';
|
|
12
|
-
export { formatCommand } from './utils.js';
|
|
12
|
+
export { formatCommand, handleSpecialURL } from './utils.js';
|
|
13
13
|
export { initStarter, compileStarter } from './custom-add-ons/starter.js';
|
|
14
14
|
export { initAddOn, compileAddOn } from './custom-add-ons/add-on.js';
|
|
15
15
|
export { createAppOptionsFromPersisted, createSerializedOptionsFromPersisted, } from './custom-add-ons/shared.js';
|
package/dist/types/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -15,3 +15,17 @@ export function jsSafeName(name) {
|
|
|
15
15
|
export function formatCommand({ command, args, }) {
|
|
16
16
|
return `${command} ${args.join(' ')}`.trim();
|
|
17
17
|
}
|
|
18
|
+
// Turn GitHub URLs into raw URLs
|
|
19
|
+
export function handleSpecialURL(url) {
|
|
20
|
+
if (url.startsWith('https://github.com/') && url.includes('blob')) {
|
|
21
|
+
return url
|
|
22
|
+
.replace('https://github.com/', 'https://raw.githubusercontent.com/')
|
|
23
|
+
.replace('/blob/', '/refs/heads/');
|
|
24
|
+
}
|
|
25
|
+
if (url.startsWith('https://github.com/') && url.includes('tree')) {
|
|
26
|
+
return url
|
|
27
|
+
.replace('https://github.com/', 'https://raw.githubusercontent.com/')
|
|
28
|
+
.replace('/tree/', '/refs/heads/');
|
|
29
|
+
}
|
|
30
|
+
return url;
|
|
31
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ export {
|
|
|
41
41
|
relativePath,
|
|
42
42
|
} from './file-helpers.js'
|
|
43
43
|
|
|
44
|
-
export { formatCommand } from './utils.js'
|
|
44
|
+
export { formatCommand, handleSpecialURL } from './utils.js'
|
|
45
45
|
|
|
46
46
|
export { initStarter, compileStarter } from './custom-add-ons/starter.js'
|
|
47
47
|
export { initAddOn, compileAddOn } from './custom-add-ons/add-on.js'
|
package/src/registry.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import { loadRemoteAddOn } from './custom-add-ons/add-on.js'
|
|
3
3
|
import { loadStarter } from './custom-add-ons/starter.js'
|
|
4
|
+
import { handleSpecialURL } from './utils.js'
|
|
4
5
|
|
|
5
6
|
import type { AddOn, Starter } from './types'
|
|
6
7
|
|
|
@@ -45,15 +46,16 @@ export async function getRawRegistry(
|
|
|
45
46
|
): Promise<Registry | undefined> {
|
|
46
47
|
const regUrl = registryUrl || process.env.CTA_REGISTRY
|
|
47
48
|
if (regUrl) {
|
|
48
|
-
const
|
|
49
|
+
const url = handleSpecialURL(regUrl)
|
|
50
|
+
const registry = (await fetch(url).then((res) => res.json())) as Registry
|
|
49
51
|
const parsedRegistry = registrySchema.parse(registry)
|
|
50
52
|
for (const addOn of parsedRegistry['add-ons'] || []) {
|
|
51
|
-
addOn.url = absolutizeUrl(
|
|
53
|
+
addOn.url = absolutizeUrl(url, addOn.url)
|
|
52
54
|
}
|
|
53
55
|
for (const starter of parsedRegistry.starters || []) {
|
|
54
|
-
starter.url = absolutizeUrl(
|
|
56
|
+
starter.url = absolutizeUrl(url, starter.url)
|
|
55
57
|
if (starter.banner) {
|
|
56
|
-
starter.banner = absolutizeUrl(
|
|
58
|
+
starter.banner = absolutizeUrl(url, starter.banner)
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
return parsedRegistry
|
package/src/utils.ts
CHANGED
|
@@ -25,3 +25,18 @@ export function formatCommand({
|
|
|
25
25
|
}) {
|
|
26
26
|
return `${command} ${args.join(' ')}`.trim()
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
// Turn GitHub URLs into raw URLs
|
|
30
|
+
export function handleSpecialURL(url: string) {
|
|
31
|
+
if (url.startsWith('https://github.com/') && url.includes('blob')) {
|
|
32
|
+
return url
|
|
33
|
+
.replace('https://github.com/', 'https://raw.githubusercontent.com/')
|
|
34
|
+
.replace('/blob/', '/refs/heads/')
|
|
35
|
+
}
|
|
36
|
+
if (url.startsWith('https://github.com/') && url.includes('tree')) {
|
|
37
|
+
return url
|
|
38
|
+
.replace('https://github.com/', 'https://raw.githubusercontent.com/')
|
|
39
|
+
.replace('/tree/', '/refs/heads/')
|
|
40
|
+
}
|
|
41
|
+
return url
|
|
42
|
+
}
|
package/tests/utils.test.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
formatCommand,
|
|
5
|
+
handleSpecialURL,
|
|
6
|
+
jsSafeName,
|
|
7
|
+
sortObject,
|
|
8
|
+
} from '../src/utils.js'
|
|
4
9
|
|
|
5
10
|
describe('formatCommand', () => {
|
|
6
11
|
it('should format a command', () => {
|
|
@@ -21,3 +26,23 @@ describe('sortObject', () => {
|
|
|
21
26
|
expect(sortObject({ b: 'b', a: 'a' })).toEqual({ a: 'a', b: 'b' })
|
|
22
27
|
})
|
|
23
28
|
})
|
|
29
|
+
|
|
30
|
+
describe('handleSpecialURL', () => {
|
|
31
|
+
it('should handle special URLs', () => {
|
|
32
|
+
expect(
|
|
33
|
+
handleSpecialURL(
|
|
34
|
+
'https://github.com/TanStack/create-tsrouter-app/blob/main/examples/react-cra/registry.json',
|
|
35
|
+
),
|
|
36
|
+
).toEqual(
|
|
37
|
+
'https://raw.githubusercontent.com/TanStack/create-tsrouter-app/refs/heads/main/examples/react-cra/registry.json',
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
expect(
|
|
41
|
+
handleSpecialURL(
|
|
42
|
+
'https://github.com/TanStack/create-tsrouter-app/tree/alpha/packages/cta-cli/tsconfig.json',
|
|
43
|
+
),
|
|
44
|
+
).toEqual(
|
|
45
|
+
'https://raw.githubusercontent.com/TanStack/create-tsrouter-app/refs/heads/alpha/packages/cta-cli/tsconfig.json',
|
|
46
|
+
)
|
|
47
|
+
})
|
|
48
|
+
})
|