genomic 4.0.2 → 5.0.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/README.md +154 -1125
- package/cache/cache-manager.d.ts +60 -0
- package/cache/cache-manager.js +228 -0
- package/cache/types.d.ts +22 -0
- package/esm/cache/cache-manager.js +191 -0
- package/esm/git/git-cloner.js +92 -0
- package/esm/index.js +41 -4
- package/esm/licenses.js +120 -0
- package/esm/scaffolder/index.js +2 -0
- package/esm/scaffolder/template-scaffolder.js +310 -0
- package/esm/scaffolder/types.js +1 -0
- package/esm/template/extract.js +162 -0
- package/esm/template/prompt.js +103 -0
- package/esm/template/replace.js +110 -0
- package/esm/template/templatizer.js +73 -0
- package/esm/template/types.js +1 -0
- package/esm/types.js +1 -0
- package/esm/utils/npm-version-check.js +52 -0
- package/esm/utils/types.js +1 -0
- package/git/git-cloner.d.ts +32 -0
- package/git/git-cloner.js +129 -0
- package/git/types.d.ts +15 -0
- package/index.d.ts +29 -4
- package/index.js +43 -4
- package/licenses-templates/APACHE-2.0.txt +18 -0
- package/licenses-templates/BSD-3-CLAUSE.txt +28 -0
- package/licenses-templates/CLOSED.txt +20 -0
- package/licenses-templates/GPL-3.0.txt +18 -0
- package/licenses-templates/ISC.txt +16 -0
- package/licenses-templates/MIT.txt +22 -0
- package/licenses-templates/MPL-2.0.txt +8 -0
- package/licenses-templates/UNLICENSE.txt +22 -0
- package/licenses.d.ts +18 -0
- package/licenses.js +162 -0
- package/package.json +9 -14
- package/scaffolder/index.d.ts +2 -0
- package/{question → scaffolder}/index.js +1 -0
- package/scaffolder/template-scaffolder.d.ts +91 -0
- package/scaffolder/template-scaffolder.js +347 -0
- package/scaffolder/types.d.ts +191 -0
- package/scaffolder/types.js +2 -0
- package/template/extract.d.ts +7 -0
- package/template/extract.js +198 -0
- package/template/prompt.d.ts +19 -0
- package/template/prompt.js +107 -0
- package/template/replace.d.ts +9 -0
- package/template/replace.js +146 -0
- package/template/templatizer.d.ts +33 -0
- package/template/templatizer.js +110 -0
- package/template/types.d.ts +18 -0
- package/template/types.js +2 -0
- package/types.d.ts +99 -0
- package/types.js +2 -0
- package/utils/npm-version-check.d.ts +17 -0
- package/utils/npm-version-check.js +57 -0
- package/utils/types.d.ts +6 -0
- package/utils/types.js +2 -0
- package/commander.d.ts +0 -21
- package/commander.js +0 -57
- package/esm/commander.js +0 -50
- package/esm/keypress.js +0 -95
- package/esm/prompt.js +0 -1024
- package/esm/question/index.js +0 -1
- package/esm/resolvers/date.js +0 -11
- package/esm/resolvers/git.js +0 -26
- package/esm/resolvers/index.js +0 -103
- package/esm/resolvers/npm.js +0 -24
- package/esm/resolvers/workspace.js +0 -141
- package/esm/utils.js +0 -12
- package/keypress.d.ts +0 -45
- package/keypress.js +0 -99
- package/prompt.d.ts +0 -116
- package/prompt.js +0 -1032
- package/question/index.d.ts +0 -1
- package/question/types.d.ts +0 -65
- package/resolvers/date.d.ts +0 -5
- package/resolvers/date.js +0 -14
- package/resolvers/git.d.ts +0 -11
- package/resolvers/git.js +0 -30
- package/resolvers/index.d.ts +0 -63
- package/resolvers/index.js +0 -111
- package/resolvers/npm.d.ts +0 -10
- package/resolvers/npm.js +0 -28
- package/resolvers/types.d.ts +0 -12
- package/resolvers/workspace.d.ts +0 -6
- package/resolvers/workspace.js +0 -144
- package/utils.d.ts +0 -2
- package/utils.js +0 -16
- /package/{question → cache}/types.js +0 -0
- /package/esm/{question → cache}/types.js +0 -0
- /package/esm/{resolvers → git}/types.js +0 -0
- /package/{resolvers → git}/types.js +0 -0
package/question/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
package/question/types.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
export interface Value {
|
|
2
|
-
name: string;
|
|
3
|
-
value: boolean;
|
|
4
|
-
}
|
|
5
|
-
export interface OptionValue {
|
|
6
|
-
name: string;
|
|
7
|
-
value: any;
|
|
8
|
-
selected?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface Validation {
|
|
11
|
-
type?: string;
|
|
12
|
-
success: boolean;
|
|
13
|
-
reason?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface BaseQuestion {
|
|
16
|
-
name: string;
|
|
17
|
-
type: string;
|
|
18
|
-
_?: boolean;
|
|
19
|
-
default?: any;
|
|
20
|
-
defaultFrom?: string;
|
|
21
|
-
setFrom?: string;
|
|
22
|
-
optionsFrom?: string;
|
|
23
|
-
useDefault?: boolean;
|
|
24
|
-
required?: boolean;
|
|
25
|
-
message?: string;
|
|
26
|
-
description?: string;
|
|
27
|
-
validate?: (input: any, obj: any) => Validation | boolean;
|
|
28
|
-
sanitize?: (input: any, obj: any) => any;
|
|
29
|
-
pattern?: string;
|
|
30
|
-
dependsOn?: string[];
|
|
31
|
-
when?: (answers: any) => boolean;
|
|
32
|
-
}
|
|
33
|
-
export interface ConfirmQuestion extends BaseQuestion {
|
|
34
|
-
type: 'confirm';
|
|
35
|
-
default?: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface AutocompleteQuestion extends BaseQuestion {
|
|
38
|
-
type: 'autocomplete';
|
|
39
|
-
options: (string | OptionValue)[];
|
|
40
|
-
maxDisplayLines?: number;
|
|
41
|
-
allowCustomOptions?: boolean;
|
|
42
|
-
}
|
|
43
|
-
export interface ListQuestion extends BaseQuestion {
|
|
44
|
-
type: 'list';
|
|
45
|
-
options: (string | OptionValue)[];
|
|
46
|
-
maxDisplayLines?: number;
|
|
47
|
-
allowCustomOptions?: boolean;
|
|
48
|
-
}
|
|
49
|
-
export interface CheckboxQuestion extends BaseQuestion {
|
|
50
|
-
type: 'checkbox';
|
|
51
|
-
options: (string | OptionValue)[];
|
|
52
|
-
maxDisplayLines?: number;
|
|
53
|
-
returnFullResults?: boolean;
|
|
54
|
-
allowCustomOptions?: boolean;
|
|
55
|
-
default?: string[];
|
|
56
|
-
}
|
|
57
|
-
export interface TextQuestion extends BaseQuestion {
|
|
58
|
-
type: 'text';
|
|
59
|
-
default?: string;
|
|
60
|
-
}
|
|
61
|
-
export interface NumberQuestion extends BaseQuestion {
|
|
62
|
-
type: 'number';
|
|
63
|
-
default?: number;
|
|
64
|
-
}
|
|
65
|
-
export type Question = ConfirmQuestion | ListQuestion | AutocompleteQuestion | CheckboxQuestion | TextQuestion | NumberQuestion;
|
package/resolvers/date.d.ts
DELETED
package/resolvers/date.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dateResolvers = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Built-in date/time resolvers.
|
|
6
|
-
*/
|
|
7
|
-
exports.dateResolvers = {
|
|
8
|
-
'date.year': () => new Date().getFullYear().toString(),
|
|
9
|
-
'date.month': () => (new Date().getMonth() + 1).toString().padStart(2, '0'),
|
|
10
|
-
'date.day': () => new Date().getDate().toString().padStart(2, '0'),
|
|
11
|
-
'date.now': () => new Date().toISOString(),
|
|
12
|
-
'date.iso': () => new Date().toISOString().split('T')[0], // YYYY-MM-DD
|
|
13
|
-
'date.timestamp': () => Date.now().toString(),
|
|
14
|
-
};
|
package/resolvers/git.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ResolverRegistry } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Retrieves a git config value.
|
|
4
|
-
* @param key The git config key (e.g., 'user.name', 'user.email')
|
|
5
|
-
* @returns The config value as a string, or undefined if not found or error occurs
|
|
6
|
-
*/
|
|
7
|
-
export declare function getGitConfig(key: string): string | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Built-in git configuration resolvers.
|
|
10
|
-
*/
|
|
11
|
-
export declare const gitResolvers: ResolverRegistry;
|
package/resolvers/git.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitResolvers = void 0;
|
|
4
|
-
exports.getGitConfig = getGitConfig;
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves a git config value.
|
|
8
|
-
* @param key The git config key (e.g., 'user.name', 'user.email')
|
|
9
|
-
* @returns The config value as a string, or undefined if not found or error occurs
|
|
10
|
-
*/
|
|
11
|
-
function getGitConfig(key) {
|
|
12
|
-
try {
|
|
13
|
-
const result = (0, child_process_1.execSync)(`git config --global ${key}`, {
|
|
14
|
-
encoding: 'utf8',
|
|
15
|
-
stdio: ['pipe', 'pipe', 'ignore'] // Suppress stderr
|
|
16
|
-
});
|
|
17
|
-
const trimmed = result.trim();
|
|
18
|
-
return trimmed || undefined; // Treat empty string as undefined
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Built-in git configuration resolvers.
|
|
26
|
-
*/
|
|
27
|
-
exports.gitResolvers = {
|
|
28
|
-
'git.user.name': () => getGitConfig('user.name'),
|
|
29
|
-
'git.user.email': () => getGitConfig('user.email'),
|
|
30
|
-
};
|
package/resolvers/index.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { DefaultResolver, ResolverRegistry } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* A registry for managing default value resolvers.
|
|
4
|
-
* Allows registration of custom resolvers and provides resolution logic.
|
|
5
|
-
*/
|
|
6
|
-
export declare class DefaultResolverRegistry {
|
|
7
|
-
private resolvers;
|
|
8
|
-
constructor(initialResolvers?: ResolverRegistry);
|
|
9
|
-
/**
|
|
10
|
-
* Register a custom resolver.
|
|
11
|
-
* @param key The resolver key (e.g., 'git.user.name')
|
|
12
|
-
* @param resolver The resolver function
|
|
13
|
-
*/
|
|
14
|
-
register(key: string, resolver: DefaultResolver): void;
|
|
15
|
-
/**
|
|
16
|
-
* Unregister a resolver.
|
|
17
|
-
* @param key The resolver key to remove
|
|
18
|
-
*/
|
|
19
|
-
unregister(key: string): void;
|
|
20
|
-
/**
|
|
21
|
-
* Resolve a key to its value.
|
|
22
|
-
* Returns undefined if the resolver doesn't exist or if it throws an error.
|
|
23
|
-
* @param key The resolver key
|
|
24
|
-
* @returns The resolved value or undefined
|
|
25
|
-
*/
|
|
26
|
-
resolve(key: string): Promise<any>;
|
|
27
|
-
/**
|
|
28
|
-
* Check if a resolver exists for the given key.
|
|
29
|
-
* @param key The resolver key
|
|
30
|
-
* @returns True if the resolver exists
|
|
31
|
-
*/
|
|
32
|
-
has(key: string): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Get all registered resolver keys.
|
|
35
|
-
* @returns Array of resolver keys
|
|
36
|
-
*/
|
|
37
|
-
keys(): string[];
|
|
38
|
-
/**
|
|
39
|
-
* Create a copy of this registry with all current resolvers.
|
|
40
|
-
* @returns A new DefaultResolverRegistry instance
|
|
41
|
-
*/
|
|
42
|
-
clone(): DefaultResolverRegistry;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Global resolver registry instance with built-in resolvers.
|
|
46
|
-
* This is the default registry used by Prompter unless a custom one is provided.
|
|
47
|
-
*/
|
|
48
|
-
export declare const globalResolverRegistry: DefaultResolverRegistry;
|
|
49
|
-
/**
|
|
50
|
-
* Convenience function to register a resolver on the global registry.
|
|
51
|
-
* @param key The resolver key
|
|
52
|
-
* @param resolver The resolver function
|
|
53
|
-
*/
|
|
54
|
-
export declare function registerDefaultResolver(key: string, resolver: DefaultResolver): void;
|
|
55
|
-
/**
|
|
56
|
-
* Convenience function to resolve a key using the global registry.
|
|
57
|
-
* @param key The resolver key
|
|
58
|
-
* @returns The resolved value or undefined
|
|
59
|
-
*/
|
|
60
|
-
export declare function resolveDefault(key: string): Promise<any>;
|
|
61
|
-
export type { DefaultResolver, ResolverRegistry } from './types';
|
|
62
|
-
export { getGitConfig } from './git';
|
|
63
|
-
export { getNpmWhoami } from './npm';
|
package/resolvers/index.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNpmWhoami = exports.getGitConfig = exports.globalResolverRegistry = exports.DefaultResolverRegistry = void 0;
|
|
4
|
-
exports.registerDefaultResolver = registerDefaultResolver;
|
|
5
|
-
exports.resolveDefault = resolveDefault;
|
|
6
|
-
const git_1 = require("./git");
|
|
7
|
-
const date_1 = require("./date");
|
|
8
|
-
const npm_1 = require("./npm");
|
|
9
|
-
const workspace_1 = require("./workspace");
|
|
10
|
-
/**
|
|
11
|
-
* A registry for managing default value resolvers.
|
|
12
|
-
* Allows registration of custom resolvers and provides resolution logic.
|
|
13
|
-
*/
|
|
14
|
-
class DefaultResolverRegistry {
|
|
15
|
-
resolvers;
|
|
16
|
-
constructor(initialResolvers = {}) {
|
|
17
|
-
this.resolvers = { ...initialResolvers };
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Register a custom resolver.
|
|
21
|
-
* @param key The resolver key (e.g., 'git.user.name')
|
|
22
|
-
* @param resolver The resolver function
|
|
23
|
-
*/
|
|
24
|
-
register(key, resolver) {
|
|
25
|
-
this.resolvers[key] = resolver;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Unregister a resolver.
|
|
29
|
-
* @param key The resolver key to remove
|
|
30
|
-
*/
|
|
31
|
-
unregister(key) {
|
|
32
|
-
delete this.resolvers[key];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Resolve a key to its value.
|
|
36
|
-
* Returns undefined if the resolver doesn't exist or if it throws an error.
|
|
37
|
-
* @param key The resolver key
|
|
38
|
-
* @returns The resolved value or undefined
|
|
39
|
-
*/
|
|
40
|
-
async resolve(key) {
|
|
41
|
-
const resolver = this.resolvers[key];
|
|
42
|
-
if (!resolver) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
const result = await Promise.resolve(resolver());
|
|
47
|
-
// Treat empty strings as undefined
|
|
48
|
-
return result === '' ? undefined : result;
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
// Silent failure - log only in debug mode
|
|
52
|
-
if (process.env.DEBUG === 'genomic') {
|
|
53
|
-
console.error(`[genomic] Resolver '${key}' failed:`, error);
|
|
54
|
-
}
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Check if a resolver exists for the given key.
|
|
60
|
-
* @param key The resolver key
|
|
61
|
-
* @returns True if the resolver exists
|
|
62
|
-
*/
|
|
63
|
-
has(key) {
|
|
64
|
-
return key in this.resolvers;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get all registered resolver keys.
|
|
68
|
-
* @returns Array of resolver keys
|
|
69
|
-
*/
|
|
70
|
-
keys() {
|
|
71
|
-
return Object.keys(this.resolvers);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Create a copy of this registry with all current resolvers.
|
|
75
|
-
* @returns A new DefaultResolverRegistry instance
|
|
76
|
-
*/
|
|
77
|
-
clone() {
|
|
78
|
-
return new DefaultResolverRegistry({ ...this.resolvers });
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.DefaultResolverRegistry = DefaultResolverRegistry;
|
|
82
|
-
/**
|
|
83
|
-
* Global resolver registry instance with built-in resolvers.
|
|
84
|
-
* This is the default registry used by Prompter unless a custom one is provided.
|
|
85
|
-
*/
|
|
86
|
-
exports.globalResolverRegistry = new DefaultResolverRegistry({
|
|
87
|
-
...git_1.gitResolvers,
|
|
88
|
-
...date_1.dateResolvers,
|
|
89
|
-
...npm_1.npmResolvers,
|
|
90
|
-
...workspace_1.workspaceResolvers,
|
|
91
|
-
});
|
|
92
|
-
/**
|
|
93
|
-
* Convenience function to register a resolver on the global registry.
|
|
94
|
-
* @param key The resolver key
|
|
95
|
-
* @param resolver The resolver function
|
|
96
|
-
*/
|
|
97
|
-
function registerDefaultResolver(key, resolver) {
|
|
98
|
-
exports.globalResolverRegistry.register(key, resolver);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Convenience function to resolve a key using the global registry.
|
|
102
|
-
* @param key The resolver key
|
|
103
|
-
* @returns The resolved value or undefined
|
|
104
|
-
*/
|
|
105
|
-
function resolveDefault(key) {
|
|
106
|
-
return exports.globalResolverRegistry.resolve(key);
|
|
107
|
-
}
|
|
108
|
-
var git_2 = require("./git");
|
|
109
|
-
Object.defineProperty(exports, "getGitConfig", { enumerable: true, get: function () { return git_2.getGitConfig; } });
|
|
110
|
-
var npm_2 = require("./npm");
|
|
111
|
-
Object.defineProperty(exports, "getNpmWhoami", { enumerable: true, get: function () { return npm_2.getNpmWhoami; } });
|
package/resolvers/npm.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ResolverRegistry } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Retrieves the currently logged in npm user.
|
|
4
|
-
* @returns The npm username, or undefined if not logged in or error occurs
|
|
5
|
-
*/
|
|
6
|
-
export declare function getNpmWhoami(): string | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Built-in npm resolvers.
|
|
9
|
-
*/
|
|
10
|
-
export declare const npmResolvers: ResolverRegistry;
|
package/resolvers/npm.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.npmResolvers = void 0;
|
|
4
|
-
exports.getNpmWhoami = getNpmWhoami;
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves the currently logged in npm user.
|
|
8
|
-
* @returns The npm username, or undefined if not logged in or error occurs
|
|
9
|
-
*/
|
|
10
|
-
function getNpmWhoami() {
|
|
11
|
-
try {
|
|
12
|
-
const result = (0, child_process_1.execSync)('npm whoami', {
|
|
13
|
-
encoding: 'utf8',
|
|
14
|
-
stdio: ['pipe', 'pipe', 'ignore'] // Suppress stderr
|
|
15
|
-
});
|
|
16
|
-
const trimmed = result.trim();
|
|
17
|
-
return trimmed || undefined; // Treat empty string as undefined
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Built-in npm resolvers.
|
|
25
|
-
*/
|
|
26
|
-
exports.npmResolvers = {
|
|
27
|
-
'npm.whoami': () => getNpmWhoami(),
|
|
28
|
-
};
|
package/resolvers/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A function that resolves a default value dynamically.
|
|
3
|
-
* Can be synchronous or asynchronous.
|
|
4
|
-
*/
|
|
5
|
-
export type DefaultResolver = () => Promise<any> | any;
|
|
6
|
-
/**
|
|
7
|
-
* A registry of resolver functions, keyed by their resolver name.
|
|
8
|
-
* Example: { 'git.user.name': () => getGitConfig('user.name') }
|
|
9
|
-
*/
|
|
10
|
-
export interface ResolverRegistry {
|
|
11
|
-
[key: string]: DefaultResolver;
|
|
12
|
-
}
|
package/resolvers/workspace.d.ts
DELETED
package/resolvers/workspace.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.workspaceResolvers = void 0;
|
|
4
|
-
const find_and_require_package_json_1 = require("find-and-require-package-json");
|
|
5
|
-
/**
|
|
6
|
-
* Find and read the nearest package.json starting from cwd.
|
|
7
|
-
* Returns undefined if not found (instead of throwing).
|
|
8
|
-
*/
|
|
9
|
-
function findPackageJsonFromCwd() {
|
|
10
|
-
try {
|
|
11
|
-
return (0, find_and_require_package_json_1.findAndRequirePackageJson)(process.cwd());
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Parse a GitHub URL and extract organization and repo name.
|
|
19
|
-
* Handles various formats:
|
|
20
|
-
* - https://github.com/org/repo
|
|
21
|
-
* - https://github.com/org/repo.git
|
|
22
|
-
* - git@github.com:org/repo.git
|
|
23
|
-
* - git://github.com/org/repo.git
|
|
24
|
-
*/
|
|
25
|
-
function parseGitHubUrl(url) {
|
|
26
|
-
if (!url) {
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
// Handle git@github.com:org/repo.git format
|
|
30
|
-
const sshMatch = url.match(/git@github\.com:([^/]+)\/([^/.]+)(?:\.git)?/);
|
|
31
|
-
if (sshMatch) {
|
|
32
|
-
return { organization: sshMatch[1], name: sshMatch[2] };
|
|
33
|
-
}
|
|
34
|
-
// Handle https://github.com/org/repo or git://github.com/org/repo formats
|
|
35
|
-
const httpsMatch = url.match(/(?:https?|git):\/\/github\.com\/([^/]+)\/([^/.]+)(?:\.git)?/);
|
|
36
|
-
if (httpsMatch) {
|
|
37
|
-
return { organization: httpsMatch[1], name: httpsMatch[2] };
|
|
38
|
-
}
|
|
39
|
-
return {};
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Get the repository URL from package.json.
|
|
43
|
-
* Handles both string and object formats.
|
|
44
|
-
*/
|
|
45
|
-
function getRepositoryUrl(pkg) {
|
|
46
|
-
if (!pkg.repository) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
if (typeof pkg.repository === 'string') {
|
|
50
|
-
return pkg.repository;
|
|
51
|
-
}
|
|
52
|
-
return pkg.repository.url;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Parse author field which can be a string or object.
|
|
56
|
-
* String format: "Name <email> (url)" where email and url are optional
|
|
57
|
-
*/
|
|
58
|
-
function parseAuthor(author) {
|
|
59
|
-
if (!author) {
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
if (typeof author === 'object') {
|
|
63
|
-
return { name: author.name, email: author.email };
|
|
64
|
-
}
|
|
65
|
-
// Parse string format: "Name <email> (url)"
|
|
66
|
-
const nameMatch = author.match(/^([^<(]+)/);
|
|
67
|
-
const emailMatch = author.match(/<([^>]+)>/);
|
|
68
|
-
return {
|
|
69
|
-
name: nameMatch ? nameMatch[1].trim() : undefined,
|
|
70
|
-
email: emailMatch ? emailMatch[1] : undefined,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Built-in workspace resolvers.
|
|
75
|
-
* These resolve values from the nearest package.json in the current working directory.
|
|
76
|
-
*/
|
|
77
|
-
exports.workspaceResolvers = {
|
|
78
|
-
'workspace.name': () => {
|
|
79
|
-
const pkg = findPackageJsonFromCwd();
|
|
80
|
-
if (!pkg)
|
|
81
|
-
return undefined;
|
|
82
|
-
const url = getRepositoryUrl(pkg);
|
|
83
|
-
// Prefer repo slug when repository is set; fall back to package name
|
|
84
|
-
if (url) {
|
|
85
|
-
const parsed = parseGitHubUrl(url);
|
|
86
|
-
if (parsed.name)
|
|
87
|
-
return parsed.name;
|
|
88
|
-
}
|
|
89
|
-
return pkg.name;
|
|
90
|
-
},
|
|
91
|
-
'workspace.repo.name': () => {
|
|
92
|
-
const pkg = findPackageJsonFromCwd();
|
|
93
|
-
if (!pkg)
|
|
94
|
-
return undefined;
|
|
95
|
-
const url = getRepositoryUrl(pkg);
|
|
96
|
-
if (!url)
|
|
97
|
-
return undefined;
|
|
98
|
-
return parseGitHubUrl(url).name;
|
|
99
|
-
},
|
|
100
|
-
'workspace.repo.organization': () => {
|
|
101
|
-
const pkg = findPackageJsonFromCwd();
|
|
102
|
-
if (!pkg)
|
|
103
|
-
return undefined;
|
|
104
|
-
const url = getRepositoryUrl(pkg);
|
|
105
|
-
if (!url)
|
|
106
|
-
return undefined;
|
|
107
|
-
return parseGitHubUrl(url).organization;
|
|
108
|
-
},
|
|
109
|
-
// Alias for repo.organization for template readability
|
|
110
|
-
'workspace.organization.name': () => {
|
|
111
|
-
const pkg = findPackageJsonFromCwd();
|
|
112
|
-
if (!pkg)
|
|
113
|
-
return undefined;
|
|
114
|
-
const url = getRepositoryUrl(pkg);
|
|
115
|
-
if (!url)
|
|
116
|
-
return undefined;
|
|
117
|
-
return parseGitHubUrl(url).organization;
|
|
118
|
-
},
|
|
119
|
-
'workspace.license': () => {
|
|
120
|
-
const pkg = findPackageJsonFromCwd();
|
|
121
|
-
return pkg?.license;
|
|
122
|
-
},
|
|
123
|
-
'workspace.author': () => {
|
|
124
|
-
const pkg = findPackageJsonFromCwd();
|
|
125
|
-
if (!pkg)
|
|
126
|
-
return undefined;
|
|
127
|
-
const parsed = parseAuthor(pkg.author);
|
|
128
|
-
return parsed.name;
|
|
129
|
-
},
|
|
130
|
-
'workspace.author.name': () => {
|
|
131
|
-
const pkg = findPackageJsonFromCwd();
|
|
132
|
-
if (!pkg)
|
|
133
|
-
return undefined;
|
|
134
|
-
const parsed = parseAuthor(pkg.author);
|
|
135
|
-
return parsed.name;
|
|
136
|
-
},
|
|
137
|
-
'workspace.author.email': () => {
|
|
138
|
-
const pkg = findPackageJsonFromCwd();
|
|
139
|
-
if (!pkg)
|
|
140
|
-
return undefined;
|
|
141
|
-
const parsed = parseAuthor(pkg.author);
|
|
142
|
-
return parsed.email;
|
|
143
|
-
},
|
|
144
|
-
};
|
package/utils.d.ts
DELETED
package/utils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.displayVersion = displayVersion;
|
|
4
|
-
exports.getVersion = getVersion;
|
|
5
|
-
const yanse_1 = require("yanse");
|
|
6
|
-
const find_and_require_package_json_1 = require("find-and-require-package-json");
|
|
7
|
-
// Function to display the version information
|
|
8
|
-
function displayVersion() {
|
|
9
|
-
const pkg = (0, find_and_require_package_json_1.findAndRequirePackageJson)(__dirname);
|
|
10
|
-
console.log((0, yanse_1.green)(`Name: ${pkg.name}`));
|
|
11
|
-
console.log((0, yanse_1.blue)(`Version: ${pkg.version}`));
|
|
12
|
-
}
|
|
13
|
-
function getVersion() {
|
|
14
|
-
const pkg = (0, find_and_require_package_json_1.findAndRequirePackageJson)(__dirname);
|
|
15
|
-
return pkg.version;
|
|
16
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|