@prompd/cli 0.3.3
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 +162 -0
- package/bin/prompd.js +23 -0
- package/dist/commands/cache.d.ts +3 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +199 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/compile.d.ts +9 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +104 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +212 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +183 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/deps.d.ts +3 -0
- package/dist/commands/deps.d.ts.map +1 -0
- package/dist/commands/deps.js +192 -0
- package/dist/commands/deps.js.map +1 -0
- package/dist/commands/explain.d.ts +3 -0
- package/dist/commands/explain.d.ts.map +1 -0
- package/dist/commands/explain.js +227 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/git.d.ts +3 -0
- package/dist/commands/git.d.ts.map +1 -0
- package/dist/commands/git.js +306 -0
- package/dist/commands/git.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +177 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +126 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +326 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/namespace.d.ts +3 -0
- package/dist/commands/namespace.d.ts.map +1 -0
- package/dist/commands/namespace.js +113 -0
- package/dist/commands/namespace.js.map +1 -0
- package/dist/commands/package.d.ts +23 -0
- package/dist/commands/package.d.ts.map +1 -0
- package/dist/commands/package.js +746 -0
- package/dist/commands/package.js.map +1 -0
- package/dist/commands/provider.d.ts +3 -0
- package/dist/commands/provider.d.ts.map +1 -0
- package/dist/commands/provider.js +285 -0
- package/dist/commands/provider.js.map +1 -0
- package/dist/commands/registry.d.ts +9 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +361 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +157 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/show.d.ts +3 -0
- package/dist/commands/show.d.ts.map +1 -0
- package/dist/commands/show.js +90 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/uninstall.d.ts +3 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +95 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +57 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +166 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/auth.d.ts +164 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +388 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/compiler/file-system.d.ts +178 -0
- package/dist/lib/compiler/file-system.d.ts.map +1 -0
- package/dist/lib/compiler/file-system.js +440 -0
- package/dist/lib/compiler/file-system.js.map +1 -0
- package/dist/lib/compiler/formatters/anthropic.d.ts +21 -0
- package/dist/lib/compiler/formatters/anthropic.d.ts.map +1 -0
- package/dist/lib/compiler/formatters/anthropic.js +95 -0
- package/dist/lib/compiler/formatters/anthropic.js.map +1 -0
- package/dist/lib/compiler/formatters/markdown.d.ts +17 -0
- package/dist/lib/compiler/formatters/markdown.d.ts.map +1 -0
- package/dist/lib/compiler/formatters/markdown.js +114 -0
- package/dist/lib/compiler/formatters/markdown.js.map +1 -0
- package/dist/lib/compiler/formatters/openai.d.ts +21 -0
- package/dist/lib/compiler/formatters/openai.d.ts.map +1 -0
- package/dist/lib/compiler/formatters/openai.js +98 -0
- package/dist/lib/compiler/formatters/openai.js.map +1 -0
- package/dist/lib/compiler/index.d.ts +56 -0
- package/dist/lib/compiler/index.d.ts.map +1 -0
- package/dist/lib/compiler/index.js +165 -0
- package/dist/lib/compiler/index.js.map +1 -0
- package/dist/lib/compiler/language-map.d.ts +31 -0
- package/dist/lib/compiler/language-map.d.ts.map +1 -0
- package/dist/lib/compiler/language-map.js +156 -0
- package/dist/lib/compiler/language-map.js.map +1 -0
- package/dist/lib/compiler/package-resolver.d.ts +68 -0
- package/dist/lib/compiler/package-resolver.d.ts.map +1 -0
- package/dist/lib/compiler/package-resolver.js +254 -0
- package/dist/lib/compiler/package-resolver.js.map +1 -0
- package/dist/lib/compiler/pipeline.d.ts +53 -0
- package/dist/lib/compiler/pipeline.d.ts.map +1 -0
- package/dist/lib/compiler/pipeline.js +209 -0
- package/dist/lib/compiler/pipeline.js.map +1 -0
- package/dist/lib/compiler/prompd-loader.d.ts +108 -0
- package/dist/lib/compiler/prompd-loader.d.ts.map +1 -0
- package/dist/lib/compiler/prompd-loader.js +270 -0
- package/dist/lib/compiler/prompd-loader.js.map +1 -0
- package/dist/lib/compiler/section-override.d.ts +40 -0
- package/dist/lib/compiler/section-override.d.ts.map +1 -0
- package/dist/lib/compiler/section-override.js +296 -0
- package/dist/lib/compiler/section-override.js.map +1 -0
- package/dist/lib/compiler/stages/assets.d.ts +71 -0
- package/dist/lib/compiler/stages/assets.d.ts.map +1 -0
- package/dist/lib/compiler/stages/assets.js +456 -0
- package/dist/lib/compiler/stages/assets.js.map +1 -0
- package/dist/lib/compiler/stages/codegen.d.ts +17 -0
- package/dist/lib/compiler/stages/codegen.d.ts.map +1 -0
- package/dist/lib/compiler/stages/codegen.js +64 -0
- package/dist/lib/compiler/stages/codegen.js.map +1 -0
- package/dist/lib/compiler/stages/dependency.d.ts +38 -0
- package/dist/lib/compiler/stages/dependency.d.ts.map +1 -0
- package/dist/lib/compiler/stages/dependency.js +307 -0
- package/dist/lib/compiler/stages/dependency.js.map +1 -0
- package/dist/lib/compiler/stages/lexical.d.ts +19 -0
- package/dist/lib/compiler/stages/lexical.d.ts.map +1 -0
- package/dist/lib/compiler/stages/lexical.js +92 -0
- package/dist/lib/compiler/stages/lexical.js.map +1 -0
- package/dist/lib/compiler/stages/semantic.d.ts +20 -0
- package/dist/lib/compiler/stages/semantic.d.ts.map +1 -0
- package/dist/lib/compiler/stages/semantic.js +166 -0
- package/dist/lib/compiler/stages/semantic.js.map +1 -0
- package/dist/lib/compiler/stages/template.d.ts +94 -0
- package/dist/lib/compiler/stages/template.d.ts.map +1 -0
- package/dist/lib/compiler/stages/template.js +1044 -0
- package/dist/lib/compiler/stages/template.js.map +1 -0
- package/dist/lib/compiler/types.d.ts +200 -0
- package/dist/lib/compiler/types.d.ts.map +1 -0
- package/dist/lib/compiler/types.js +137 -0
- package/dist/lib/compiler/types.js.map +1 -0
- package/dist/lib/config.d.ts +29 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +375 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/errors.d.ts +19 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +47 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/executor.d.ts +18 -0
- package/dist/lib/executor.d.ts.map +1 -0
- package/dist/lib/executor.js +372 -0
- package/dist/lib/executor.js.map +1 -0
- package/dist/lib/git.d.ts +74 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +254 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/index.d.ts +43 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +108 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/mcp.d.ts +42 -0
- package/dist/lib/mcp.d.ts.map +1 -0
- package/dist/lib/mcp.js +477 -0
- package/dist/lib/mcp.js.map +1 -0
- package/dist/lib/model-updater.d.ts +51 -0
- package/dist/lib/model-updater.d.ts.map +1 -0
- package/dist/lib/model-updater.js +275 -0
- package/dist/lib/model-updater.js.map +1 -0
- package/dist/lib/parser.d.ts +9 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +197 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/registry.d.ts +183 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +786 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/lib/rpc-server.d.ts +78 -0
- package/dist/lib/rpc-server.d.ts.map +1 -0
- package/dist/lib/rpc-server.js +404 -0
- package/dist/lib/rpc-server.js.map +1 -0
- package/dist/lib/security.d.ts +120 -0
- package/dist/lib/security.d.ts.map +1 -0
- package/dist/lib/security.js +478 -0
- package/dist/lib/security.js.map +1 -0
- package/dist/lib/validation.d.ts +106 -0
- package/dist/lib/validation.d.ts.map +1 -0
- package/dist/lib/validation.js +398 -0
- package/dist/lib/validation.js.map +1 -0
- package/dist/lib/version.d.ts +29 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +202 -0
- package/dist/lib/version.js.map +1 -0
- package/dist/lib/workflow-engine.d.ts +161 -0
- package/dist/lib/workflow-engine.d.ts.map +1 -0
- package/dist/lib/workflow-engine.js +422 -0
- package/dist/lib/workflow-engine.js.map +1 -0
- package/dist/lib/workflow.d.ts +102 -0
- package/dist/lib/workflow.d.ts.map +1 -0
- package/dist/lib/workflow.js +228 -0
- package/dist/lib/workflow.js.map +1 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +134 -0
- package/dist/server.js.map +1 -0
- package/dist/types/index.d.ts +116 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +144 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Language Mapping Utilities
|
|
4
|
+
*
|
|
5
|
+
* Centralized file extension to programming language mappings
|
|
6
|
+
* used across the compilation pipeline for:
|
|
7
|
+
* - Wrapping extracted code files in markdown code blocks
|
|
8
|
+
* - Filtering code blocks based on context file types
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.EXTENSION_TO_LANGUAGE_ALIASES = exports.EXTENSION_TO_LANGUAGE = void 0;
|
|
12
|
+
exports.getLanguageForExtension = getLanguageForExtension;
|
|
13
|
+
exports.getLanguageAliasesForExtension = getLanguageAliasesForExtension;
|
|
14
|
+
/**
|
|
15
|
+
* Map of file extensions to primary markdown code block language identifier.
|
|
16
|
+
* Used when wrapping extracted code files in markdown code blocks.
|
|
17
|
+
*/
|
|
18
|
+
exports.EXTENSION_TO_LANGUAGE = {
|
|
19
|
+
// TypeScript/JavaScript
|
|
20
|
+
'.ts': 'typescript',
|
|
21
|
+
'.tsx': 'typescript',
|
|
22
|
+
'.js': 'javascript',
|
|
23
|
+
'.jsx': 'javascript',
|
|
24
|
+
'.mjs': 'javascript',
|
|
25
|
+
'.cjs': 'javascript',
|
|
26
|
+
// Python
|
|
27
|
+
'.py': 'python',
|
|
28
|
+
'.pyw': 'python',
|
|
29
|
+
// Go
|
|
30
|
+
'.go': 'go',
|
|
31
|
+
// Rust
|
|
32
|
+
'.rs': 'rust',
|
|
33
|
+
// Java/Kotlin
|
|
34
|
+
'.java': 'java',
|
|
35
|
+
'.kt': 'kotlin',
|
|
36
|
+
'.kts': 'kotlin',
|
|
37
|
+
// C/C++
|
|
38
|
+
'.c': 'c',
|
|
39
|
+
'.h': 'c',
|
|
40
|
+
'.cpp': 'cpp',
|
|
41
|
+
'.hpp': 'cpp',
|
|
42
|
+
'.cc': 'cpp',
|
|
43
|
+
// C#
|
|
44
|
+
'.cs': 'csharp',
|
|
45
|
+
// Ruby
|
|
46
|
+
'.rb': 'ruby',
|
|
47
|
+
// PHP
|
|
48
|
+
'.php': 'php',
|
|
49
|
+
// Swift
|
|
50
|
+
'.swift': 'swift',
|
|
51
|
+
// Shell
|
|
52
|
+
'.sh': 'bash',
|
|
53
|
+
'.bash': 'bash',
|
|
54
|
+
'.zsh': 'zsh',
|
|
55
|
+
'.fish': 'fish',
|
|
56
|
+
// SQL
|
|
57
|
+
'.sql': 'sql',
|
|
58
|
+
// Web
|
|
59
|
+
'.html': 'html',
|
|
60
|
+
'.htm': 'html',
|
|
61
|
+
'.css': 'css',
|
|
62
|
+
'.scss': 'scss',
|
|
63
|
+
'.sass': 'sass',
|
|
64
|
+
'.less': 'less',
|
|
65
|
+
// Data formats
|
|
66
|
+
'.xml': 'xml',
|
|
67
|
+
'.svg': 'xml',
|
|
68
|
+
'.json': 'json',
|
|
69
|
+
'.yaml': 'yaml',
|
|
70
|
+
'.yml': 'yaml',
|
|
71
|
+
'.toml': 'toml',
|
|
72
|
+
'.csv': 'csv',
|
|
73
|
+
// Markdown
|
|
74
|
+
'.md': 'markdown',
|
|
75
|
+
'.mdx': 'markdown',
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Map of file extensions to all valid code block language identifiers.
|
|
79
|
+
* Used when filtering code blocks - includes aliases (e.g., 'ts' for 'typescript').
|
|
80
|
+
*/
|
|
81
|
+
exports.EXTENSION_TO_LANGUAGE_ALIASES = {
|
|
82
|
+
// TypeScript/JavaScript
|
|
83
|
+
'.ts': ['typescript', 'ts'],
|
|
84
|
+
'.tsx': ['typescript', 'tsx', 'ts'],
|
|
85
|
+
'.js': ['javascript', 'js'],
|
|
86
|
+
'.jsx': ['javascript', 'jsx', 'js'],
|
|
87
|
+
'.mjs': ['javascript', 'js'],
|
|
88
|
+
'.cjs': ['javascript', 'js'],
|
|
89
|
+
// Python
|
|
90
|
+
'.py': ['python', 'py'],
|
|
91
|
+
'.pyw': ['python', 'py'],
|
|
92
|
+
// Go
|
|
93
|
+
'.go': ['go', 'golang'],
|
|
94
|
+
// Rust
|
|
95
|
+
'.rs': ['rust', 'rs'],
|
|
96
|
+
// Java/Kotlin
|
|
97
|
+
'.java': ['java'],
|
|
98
|
+
'.kt': ['kotlin', 'kt'],
|
|
99
|
+
'.kts': ['kotlin', 'kt'],
|
|
100
|
+
// C/C++
|
|
101
|
+
'.c': ['c'],
|
|
102
|
+
'.h': ['c', 'h'],
|
|
103
|
+
'.cpp': ['cpp', 'c++', 'cxx'],
|
|
104
|
+
'.hpp': ['cpp', 'c++', 'hpp'],
|
|
105
|
+
'.cc': ['cpp', 'c++'],
|
|
106
|
+
// C#
|
|
107
|
+
'.cs': ['csharp', 'cs', 'c#'],
|
|
108
|
+
// Ruby
|
|
109
|
+
'.rb': ['ruby', 'rb'],
|
|
110
|
+
// PHP
|
|
111
|
+
'.php': ['php'],
|
|
112
|
+
// Swift
|
|
113
|
+
'.swift': ['swift'],
|
|
114
|
+
// Shell
|
|
115
|
+
'.sh': ['bash', 'sh', 'shell'],
|
|
116
|
+
'.bash': ['bash', 'sh', 'shell'],
|
|
117
|
+
'.zsh': ['zsh', 'sh', 'shell'],
|
|
118
|
+
'.fish': ['fish'],
|
|
119
|
+
// SQL
|
|
120
|
+
'.sql': ['sql'],
|
|
121
|
+
// Web
|
|
122
|
+
'.html': ['html', 'htm'],
|
|
123
|
+
'.htm': ['html', 'htm'],
|
|
124
|
+
'.css': ['css'],
|
|
125
|
+
'.scss': ['scss', 'sass'],
|
|
126
|
+
'.sass': ['sass', 'scss'],
|
|
127
|
+
'.less': ['less'],
|
|
128
|
+
// Data formats
|
|
129
|
+
'.json': ['json'],
|
|
130
|
+
'.yaml': ['yaml', 'yml'],
|
|
131
|
+
'.yml': ['yaml', 'yml'],
|
|
132
|
+
'.xml': ['xml'],
|
|
133
|
+
'.svg': ['xml', 'svg'],
|
|
134
|
+
'.toml': ['toml'],
|
|
135
|
+
'.csv': ['csv'],
|
|
136
|
+
// Markdown
|
|
137
|
+
'.md': ['markdown', 'md'],
|
|
138
|
+
'.mdx': ['mdx', 'markdown', 'md'],
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Get the primary language identifier for a file extension.
|
|
142
|
+
* @param ext - File extension (e.g., '.ts')
|
|
143
|
+
* @returns Primary language identifier or undefined
|
|
144
|
+
*/
|
|
145
|
+
function getLanguageForExtension(ext) {
|
|
146
|
+
return exports.EXTENSION_TO_LANGUAGE[ext.toLowerCase()];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get all valid language identifiers (including aliases) for a file extension.
|
|
150
|
+
* @param ext - File extension (e.g., '.ts')
|
|
151
|
+
* @returns Array of language identifiers or empty array
|
|
152
|
+
*/
|
|
153
|
+
function getLanguageAliasesForExtension(ext) {
|
|
154
|
+
return exports.EXTENSION_TO_LANGUAGE_ALIASES[ext.toLowerCase()] || [];
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=language-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-map.js","sourceRoot":"","sources":["../../../src/lib/compiler/language-map.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAuIH,0DAEC;AAOD,wEAEC;AAhJD;;;GAGG;AACU,QAAA,qBAAqB,GAA2B;IAC3D,wBAAwB;IACxB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,SAAS;IACT,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,KAAK;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N,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACxB,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,MAAM,EAAE,CAAC,KAAK,CAAC;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,CAAC,MAAM,CAAC;IACjB,eAAe;IACf,OAAO,EAAE,CAAC,MAAM,CAAC;IACjB,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACxB,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,MAAM,EAAE,CAAC,KAAK,CAAC;IACf,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,OAAO,EAAE,CAAC,MAAM,CAAC;IACjB,MAAM,EAAE,CAAC,KAAK,CAAC;IACf,WAAW;IACX,KAAK,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;IACzB,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,GAAW;IACjD,OAAO,6BAAqB,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,SAAgB,8BAA8B,CAAC,GAAW;IACxD,OAAO,qCAA6B,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package Resolution Utilities
|
|
3
|
+
*
|
|
4
|
+
* Handles resolution of package references to local file paths,
|
|
5
|
+
* including registry discovery via /.well-known/registry.json
|
|
6
|
+
*/
|
|
7
|
+
import { IFileSystem } from './file-system';
|
|
8
|
+
/**
|
|
9
|
+
* Options for package resolution.
|
|
10
|
+
*/
|
|
11
|
+
export interface ResolvePackageOptions {
|
|
12
|
+
/** File system to use (for in-memory package resolution) */
|
|
13
|
+
fileSystem?: IFileSystem;
|
|
14
|
+
/** Registry URL for downloading packages */
|
|
15
|
+
registryUrl?: string;
|
|
16
|
+
/** Workspace root directory for local package cache */
|
|
17
|
+
workspaceRoot?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a package reference to a local file path or in-memory path.
|
|
21
|
+
*
|
|
22
|
+
* @param packageRef - Package reference in format: @namespace/package@version
|
|
23
|
+
* @param fileSystemOrOptions - Optional file system or options object
|
|
24
|
+
* @param registryUrl - Optional registry URL (deprecated, use options object)
|
|
25
|
+
* @returns Resolved local path to the package directory (or virtual path for MemoryFileSystem)
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolvePackage(packageRef: string, fileSystemOrOptions?: IFileSystem | ResolvePackageOptions, registryUrl?: string): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Parse package reference into name and version.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parsePackageReference(packageRef: string): {
|
|
32
|
+
name: string;
|
|
33
|
+
version: string;
|
|
34
|
+
scope?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Validate package reference format.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isValidPackageReference(packageRef: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get the global package cache directory (~/.prompd/cache/).
|
|
42
|
+
*/
|
|
43
|
+
export declare function getGlobalCacheDir(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Get the local project package cache directory (./.prompd/cache/).
|
|
46
|
+
* @param workspaceRoot - Optional workspace root directory. If not provided, uses process.cwd()
|
|
47
|
+
*/
|
|
48
|
+
export declare function getLocalCacheDir(workspaceRoot?: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Get the package cache directory (for backward compatibility).
|
|
51
|
+
* @deprecated Use getGlobalCacheDir() or getLocalCacheDir() instead
|
|
52
|
+
*/
|
|
53
|
+
export declare function getPackageCacheDir(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Resolve a file path within a package.
|
|
56
|
+
*
|
|
57
|
+
* @param packagePath - Base path to package directory
|
|
58
|
+
* @param filePath - Relative file path within package
|
|
59
|
+
* @returns Resolved absolute path
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolvePackageFile(packagePath: string, filePath: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a package is installed (in local or global cache).
|
|
64
|
+
* @param packageRef - Package reference to check
|
|
65
|
+
* @param workspaceRoot - Optional workspace root directory for local cache
|
|
66
|
+
*/
|
|
67
|
+
export declare function isPackageInstalled(packageRef: string, workspaceRoot?: string): Promise<boolean>;
|
|
68
|
+
//# sourceMappingURL=package-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-resolver.d.ts","sourceRoot":"","sources":["../../../src/lib/compiler/package-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAAE,WAAW,EAAoB,MAAM,eAAe,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,mBAAmB,CAAC,EAAE,WAAW,GAAG,qBAAqB,EACzD,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAwGjB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAgB3G;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAoBnE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAehF;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBrG"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Package Resolution Utilities
|
|
4
|
+
*
|
|
5
|
+
* Handles resolution of package references to local file paths,
|
|
6
|
+
* including registry discovery via /.well-known/registry.json
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.resolvePackage = resolvePackage;
|
|
43
|
+
exports.parsePackageReference = parsePackageReference;
|
|
44
|
+
exports.isValidPackageReference = isValidPackageReference;
|
|
45
|
+
exports.getGlobalCacheDir = getGlobalCacheDir;
|
|
46
|
+
exports.getLocalCacheDir = getLocalCacheDir;
|
|
47
|
+
exports.getPackageCacheDir = getPackageCacheDir;
|
|
48
|
+
exports.resolvePackageFile = resolvePackageFile;
|
|
49
|
+
exports.isPackageInstalled = isPackageInstalled;
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const fs = __importStar(require("fs-extra"));
|
|
52
|
+
const os = __importStar(require("os"));
|
|
53
|
+
const registry_1 = require("../registry");
|
|
54
|
+
const errors_1 = require("../errors");
|
|
55
|
+
const file_system_1 = require("./file-system");
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a package reference to a local file path or in-memory path.
|
|
58
|
+
*
|
|
59
|
+
* @param packageRef - Package reference in format: @namespace/package@version
|
|
60
|
+
* @param fileSystemOrOptions - Optional file system or options object
|
|
61
|
+
* @param registryUrl - Optional registry URL (deprecated, use options object)
|
|
62
|
+
* @returns Resolved local path to the package directory (or virtual path for MemoryFileSystem)
|
|
63
|
+
*/
|
|
64
|
+
async function resolvePackage(packageRef, fileSystemOrOptions, registryUrl) {
|
|
65
|
+
// Handle both legacy (fileSystem, registryUrl) and new (options) signatures
|
|
66
|
+
let fileSystem;
|
|
67
|
+
let resolvedRegistryUrl;
|
|
68
|
+
let workspaceRoot;
|
|
69
|
+
if (fileSystemOrOptions && 'exists' in fileSystemOrOptions) {
|
|
70
|
+
// Legacy: fileSystem passed directly
|
|
71
|
+
fileSystem = fileSystemOrOptions;
|
|
72
|
+
resolvedRegistryUrl = registryUrl;
|
|
73
|
+
}
|
|
74
|
+
else if (fileSystemOrOptions) {
|
|
75
|
+
// New: options object
|
|
76
|
+
const opts = fileSystemOrOptions;
|
|
77
|
+
fileSystem = opts.fileSystem;
|
|
78
|
+
resolvedRegistryUrl = opts.registryUrl;
|
|
79
|
+
workspaceRoot = opts.workspaceRoot;
|
|
80
|
+
}
|
|
81
|
+
// Security: Validate package reference format
|
|
82
|
+
if (!isValidPackageReference(packageRef)) {
|
|
83
|
+
throw new errors_1.SecurityError(`Invalid package reference format: ${packageRef}`);
|
|
84
|
+
}
|
|
85
|
+
// Parse package reference
|
|
86
|
+
const { name, version } = parsePackageReference(packageRef);
|
|
87
|
+
// Handle in-memory file system
|
|
88
|
+
if (fileSystem instanceof file_system_1.MemoryFileSystem) {
|
|
89
|
+
const packagePath = fileSystem.getPackagePath(name, version);
|
|
90
|
+
// Check if package already loaded in memory
|
|
91
|
+
if (fileSystem.exists(packagePath)) {
|
|
92
|
+
return packagePath;
|
|
93
|
+
}
|
|
94
|
+
// Package not in memory - download and add it
|
|
95
|
+
try {
|
|
96
|
+
// Create registry client with optional URL override
|
|
97
|
+
const registry = new registry_1.RegistryClient(resolvedRegistryUrl ? { registryUrl: resolvedRegistryUrl } : undefined);
|
|
98
|
+
// Create download function for MemoryFileSystem
|
|
99
|
+
const downloadFn = async (pkgName, pkgVersion) => {
|
|
100
|
+
return await registry.downloadPackageBuffer(pkgName, pkgVersion);
|
|
101
|
+
};
|
|
102
|
+
await fileSystem.addPackageFromRegistry(packageRef, downloadFn);
|
|
103
|
+
return packagePath;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw new Error(`Failed to load package into memory ${packageRef}: ${error instanceof Error ? error.message : String(error)}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Default: disk-based resolution
|
|
110
|
+
// Resolution order (matches Python CLI):
|
|
111
|
+
// 1. Check local project cache (./.prompd/cache/)
|
|
112
|
+
// 2. Check global cache (~/.prompd/cache/)
|
|
113
|
+
// 3. Download from registry
|
|
114
|
+
// Package path follows Python CLI structure: @namespace/package-name/version
|
|
115
|
+
// e.g., @prompd/public-examples -> cache/@prompd/public-examples/1.1.0/
|
|
116
|
+
// Also check legacy format: @namespace/package-name@version (frontend packageCache)
|
|
117
|
+
const localCacheDir = getLocalCacheDir(workspaceRoot);
|
|
118
|
+
const globalCacheDir = getGlobalCacheDir();
|
|
119
|
+
// Check local project cache first (both formats)
|
|
120
|
+
const localPackageDir = path.join(localCacheDir, name, version);
|
|
121
|
+
if (await fs.pathExists(localPackageDir)) {
|
|
122
|
+
return localPackageDir;
|
|
123
|
+
}
|
|
124
|
+
// Legacy format: name@version as single directory (frontend packageCache.ts format)
|
|
125
|
+
const localPackageDirLegacy = path.join(localCacheDir, `${name}@${version}`);
|
|
126
|
+
if (await fs.pathExists(localPackageDirLegacy)) {
|
|
127
|
+
return localPackageDirLegacy;
|
|
128
|
+
}
|
|
129
|
+
// Check global cache (both formats)
|
|
130
|
+
const globalPackageDir = path.join(globalCacheDir, name, version);
|
|
131
|
+
if (await fs.pathExists(globalPackageDir)) {
|
|
132
|
+
return globalPackageDir;
|
|
133
|
+
}
|
|
134
|
+
const globalPackageDirLegacy = path.join(globalCacheDir, `${name}@${version}`);
|
|
135
|
+
if (await fs.pathExists(globalPackageDirLegacy)) {
|
|
136
|
+
return globalPackageDirLegacy;
|
|
137
|
+
}
|
|
138
|
+
// Package not cached - try to install it
|
|
139
|
+
try {
|
|
140
|
+
// Create registry client with optional URL override
|
|
141
|
+
const registry = new registry_1.RegistryClient(resolvedRegistryUrl ? { registryUrl: resolvedRegistryUrl } : undefined);
|
|
142
|
+
await registry.install(packageRef, { skipCache: false });
|
|
143
|
+
// After installation, check both caches again
|
|
144
|
+
if (await fs.pathExists(localPackageDir)) {
|
|
145
|
+
return localPackageDir;
|
|
146
|
+
}
|
|
147
|
+
if (await fs.pathExists(globalPackageDir)) {
|
|
148
|
+
return globalPackageDir;
|
|
149
|
+
}
|
|
150
|
+
throw new Error(`Package installation succeeded but package not found in cache: ${packageRef}`);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
throw new Error(`Failed to resolve package ${packageRef}: ${error instanceof Error ? error.message : String(error)}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Parse package reference into name and version.
|
|
158
|
+
*/
|
|
159
|
+
function parsePackageReference(packageRef) {
|
|
160
|
+
// Format: @namespace/package@version or @namespace/package (latest)
|
|
161
|
+
const match = packageRef.match(/^(@[\w.-]+\/[\w.-]+)@?([\w.-]+)?$/);
|
|
162
|
+
if (!match) {
|
|
163
|
+
throw new Error(`Invalid package reference format: ${packageRef}`);
|
|
164
|
+
}
|
|
165
|
+
const name = match[1];
|
|
166
|
+
const version = match[2] || 'latest';
|
|
167
|
+
// Extract scope
|
|
168
|
+
const scopeMatch = name.match(/^(@[\w.-]+)\//);
|
|
169
|
+
const scope = scopeMatch ? scopeMatch[1] : undefined;
|
|
170
|
+
return { name, version, scope };
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Validate package reference format.
|
|
174
|
+
*/
|
|
175
|
+
function isValidPackageReference(packageRef) {
|
|
176
|
+
// Security: Ensure package ref follows npm-style scoped package format
|
|
177
|
+
// Format: @namespace/package@version
|
|
178
|
+
const pattern = /^@[\w.-]+\/[\w.-]+(@[\w.-]+)?$/;
|
|
179
|
+
if (!pattern.test(packageRef)) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
// Security: Check for path traversal attempts
|
|
183
|
+
if (packageRef.includes('..') || packageRef.includes('//')) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
// Security: Check for null bytes
|
|
187
|
+
if (packageRef.includes('\0')) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get the global package cache directory (~/.prompd/cache/).
|
|
194
|
+
*/
|
|
195
|
+
function getGlobalCacheDir() {
|
|
196
|
+
return path.join(os.homedir(), '.prompd', 'cache');
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get the local project package cache directory (./.prompd/cache/).
|
|
200
|
+
* @param workspaceRoot - Optional workspace root directory. If not provided, uses process.cwd()
|
|
201
|
+
*/
|
|
202
|
+
function getLocalCacheDir(workspaceRoot) {
|
|
203
|
+
const basePath = workspaceRoot || process.cwd();
|
|
204
|
+
return path.join(basePath, '.prompd', 'cache');
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get the package cache directory (for backward compatibility).
|
|
208
|
+
* @deprecated Use getGlobalCacheDir() or getLocalCacheDir() instead
|
|
209
|
+
*/
|
|
210
|
+
function getPackageCacheDir() {
|
|
211
|
+
return getGlobalCacheDir();
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Resolve a file path within a package.
|
|
215
|
+
*
|
|
216
|
+
* @param packagePath - Base path to package directory
|
|
217
|
+
* @param filePath - Relative file path within package
|
|
218
|
+
* @returns Resolved absolute path
|
|
219
|
+
*/
|
|
220
|
+
function resolvePackageFile(packagePath, filePath) {
|
|
221
|
+
// Security: Path traversal protection
|
|
222
|
+
const normalized = path.normalize(filePath);
|
|
223
|
+
if (normalized.startsWith('..') || path.isAbsolute(normalized)) {
|
|
224
|
+
throw new errors_1.SecurityError(`Invalid file path within package: ${filePath}`);
|
|
225
|
+
}
|
|
226
|
+
const resolvedPath = path.join(packagePath, normalized);
|
|
227
|
+
// Security: Ensure resolved path is within package directory
|
|
228
|
+
if (!resolvedPath.startsWith(packagePath)) {
|
|
229
|
+
throw new errors_1.SecurityError(`Path traversal detected: ${filePath}`);
|
|
230
|
+
}
|
|
231
|
+
return resolvedPath;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Check if a package is installed (in local or global cache).
|
|
235
|
+
* @param packageRef - Package reference to check
|
|
236
|
+
* @param workspaceRoot - Optional workspace root directory for local cache
|
|
237
|
+
*/
|
|
238
|
+
async function isPackageInstalled(packageRef, workspaceRoot) {
|
|
239
|
+
try {
|
|
240
|
+
const { name, version } = parsePackageReference(packageRef);
|
|
241
|
+
// Check local cache first
|
|
242
|
+
const localPackageDir = path.join(getLocalCacheDir(workspaceRoot), name, version);
|
|
243
|
+
if (await fs.pathExists(localPackageDir)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
// Check global cache
|
|
247
|
+
const globalPackageDir = path.join(getGlobalCacheDir(), name, version);
|
|
248
|
+
return await fs.pathExists(globalPackageDir);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=package-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-resolver.js","sourceRoot":"","sources":["../../../src/lib/compiler/package-resolver.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BH,wCA4GC;AAKD,sDAgBC;AAKD,0DAoBC;AAKD,8CAEC;AAMD,4CAGC;AAMD,gDAEC;AASD,gDAeC;AAOD,gDAgBC;AA5PD,2CAA6B;AAC7B,6CAA+B;AAC/B,uCAAyB;AACzB,0CAA6C;AAC7C,sCAA0C;AAC1C,+CAA8D;AAc9D;;;;;;;GAOG;AACI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AqB;QACrB,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACvE,OAAO,MAAM,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compilation pipeline orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Manages the execution of the 6-stage compilation pipeline, ensuring stages
|
|
5
|
+
* run in order and errors are properly propagated.
|
|
6
|
+
*/
|
|
7
|
+
import { CompilationContext, CompilationOptions, CompilerStage, SecurityConfig } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* The main compiler pipeline orchestrator.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CompilerPipeline {
|
|
12
|
+
private stages;
|
|
13
|
+
private securityConfig;
|
|
14
|
+
constructor(stages?: CompilerStage[], securityConfig?: SecurityConfig);
|
|
15
|
+
/**
|
|
16
|
+
* Register a compilation stage.
|
|
17
|
+
*/
|
|
18
|
+
registerStage(stage: CompilerStage): void;
|
|
19
|
+
/**
|
|
20
|
+
* Execute the compilation pipeline.
|
|
21
|
+
*
|
|
22
|
+
* @param source - Path to .prmd file or package reference
|
|
23
|
+
* @param options - Compilation options
|
|
24
|
+
* @returns Compilation context with result or errors
|
|
25
|
+
*/
|
|
26
|
+
execute(source: string, options?: CompilationOptions): Promise<CompilationContext>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve source to file path (handles package references).
|
|
29
|
+
*
|
|
30
|
+
* @param source - Package reference or file path
|
|
31
|
+
* @param fileSystem - File system to use for resolution
|
|
32
|
+
* @param customFileSystem - Optional custom file system (used to detect in-memory mode)
|
|
33
|
+
* @param registryUrl - Optional registry URL for package resolution
|
|
34
|
+
* @param workspaceRoot - Optional workspace root for package cache location
|
|
35
|
+
*/
|
|
36
|
+
private resolveSource;
|
|
37
|
+
/**
|
|
38
|
+
* Find all .prmd files in a directory.
|
|
39
|
+
*
|
|
40
|
+
* @param dir - Directory path
|
|
41
|
+
* @param fileSystem - File system to use
|
|
42
|
+
*/
|
|
43
|
+
private findPromdFiles;
|
|
44
|
+
/**
|
|
45
|
+
* Validate source file for security.
|
|
46
|
+
*/
|
|
47
|
+
private validateSourceFile;
|
|
48
|
+
/**
|
|
49
|
+
* Get registered stages.
|
|
50
|
+
*/
|
|
51
|
+
getStages(): CompilerStage[];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/lib/compiler/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EAEb,cAAc,EACf,MAAM,SAAS,CAAC;AAIjB;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,cAAc,CAAiB;gBAE3B,MAAM,CAAC,EAAE,aAAa,EAAE,EAAE,cAAc,CAAC,EAAE,cAAc;IAKrE;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAIzC;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoC5F;;;;;;;;OAQG;YACW,aAAa;IAuC3B;;;;;OAKG;YACW,cAAc;IAyB5B;;OAEG;YACW,kBAAkB;IAoChC;;OAEG;IACH,SAAS,IAAI,aAAa,EAAE;CAG7B"}
|