@ketrics/ketrics-cli 0.4.0 → 0.6.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/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +15 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/create.d.ts +1 -0
- package/dist/src/commands/create.d.ts.map +1 -1
- package/dist/src/commands/create.js +44 -13
- package/dist/src/commands/create.js.map +1 -1
- package/dist/src/commands/update.d.ts +13 -0
- package/dist/src/commands/update.d.ts.map +1 -0
- package/dist/src/commands/update.js +78 -0
- package/dist/src/commands/update.js.map +1 -0
- package/dist/src/services/local-template-service.d.ts +52 -0
- package/dist/src/services/local-template-service.d.ts.map +1 -0
- package/dist/src/services/local-template-service.js +216 -0
- package/dist/src/services/local-template-service.js.map +1 -0
- package/dist/src/services/remote-template-service.d.ts +41 -0
- package/dist/src/services/remote-template-service.d.ts.map +1 -0
- package/dist/src/services/remote-template-service.js +232 -0
- package/dist/src/services/remote-template-service.js.map +1 -0
- package/dist/src/services/template-cache-service.d.ts +44 -0
- package/dist/src/services/template-cache-service.d.ts.map +1 -0
- package/dist/src/services/template-cache-service.js +193 -0
- package/dist/src/services/template-cache-service.js.map +1 -0
- package/dist/src/services/template-service.d.ts +25 -31
- package/dist/src/services/template-service.d.ts.map +1 -1
- package/dist/src/services/template-service.js +136 -132
- package/dist/src/services/template-service.js.map +1 -1
- package/dist/src/types/index.d.ts +46 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +5 -1
- package/templates/HelloWorld/.claude/skills/ketrics-app/BACKEND_REFERENCE.md +693 -0
- package/templates/HelloWorld/.claude/skills/ketrics-app/CONFIG_AND_DEPLOY.md +278 -0
- package/templates/HelloWorld/.claude/skills/ketrics-app/FRONTEND_REFERENCE.md +325 -0
- package/templates/HelloWorld/.claude/skills/ketrics-app/SKILL.md +348 -0
- package/templates/HelloWorld/.env.example +20 -0
- package/templates/HelloWorld/.github/workflows/deploy.yml +51 -0
- package/templates/HelloWorld/backend/package.json +1 -1
package/dist/src/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CA+EnC"}
|
package/dist/src/cli.js
CHANGED
|
@@ -12,6 +12,7 @@ const build_1 = require("./commands/build");
|
|
|
12
12
|
const deploy_1 = require("./commands/deploy");
|
|
13
13
|
const validate_1 = require("./commands/validate");
|
|
14
14
|
const run_1 = require("./commands/run");
|
|
15
|
+
const update_1 = require("./commands/update");
|
|
15
16
|
const version_1 = require("./version");
|
|
16
17
|
/**
|
|
17
18
|
* Create and configure CLI program
|
|
@@ -27,9 +28,15 @@ function createCLI() {
|
|
|
27
28
|
.command("create <app-name>")
|
|
28
29
|
.description("Create a new Ketrics application from a template")
|
|
29
30
|
.option("-t, --template <name>", "Use specific template (skip interactive selection)")
|
|
31
|
+
.option("--refresh", "Force refresh template list from remote")
|
|
32
|
+
.option("--local", "Use only bundled templates (skip remote fetch)")
|
|
33
|
+
.option("--clear-cache", "Clear cached templates")
|
|
30
34
|
.action(async (appName, options) => {
|
|
31
35
|
await (0, create_1.createCommand)(appName, {
|
|
32
36
|
template: options.template,
|
|
37
|
+
refresh: options.refresh,
|
|
38
|
+
local: options.local,
|
|
39
|
+
clearCache: options.clearCache,
|
|
33
40
|
});
|
|
34
41
|
});
|
|
35
42
|
// Build command
|
|
@@ -72,6 +79,14 @@ function createCLI() {
|
|
|
72
79
|
verbose: options.verbose,
|
|
73
80
|
});
|
|
74
81
|
});
|
|
82
|
+
// Update command
|
|
83
|
+
program
|
|
84
|
+
.command("update")
|
|
85
|
+
.description("Update Ketrics CLI to the latest version")
|
|
86
|
+
.option("--check", "Show the currently installed version without updating")
|
|
87
|
+
.action(async (options) => {
|
|
88
|
+
await (0, update_1.updateCommand)({ check: options.check });
|
|
89
|
+
});
|
|
75
90
|
return program;
|
|
76
91
|
}
|
|
77
92
|
//# sourceMappingURL=cli.js.map
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAcH,8BA+EC;AA3FD,yCAAoC;AACpC,8CAAkD;AAClD,4CAAgD;AAChD,8CAAkD;AAClD,kDAAsD;AACtD,wCAA4C;AAC5C,8CAAkD;AAClD,uCAAoC;AAEpC;;GAEG;AACH,SAAgB,SAAS;IACvB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,SAAS,CAAC;SACf,WAAW,CAAC,yDAAyD,CAAC;SACtE,OAAO,CAAC,iBAAO,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC;IAEzD,iBAAiB;IACjB,OAAO;SACJ,OAAO,CAAC,mBAAmB,CAAC;SAC5B,WAAW,CAAC,kDAAkD,CAAC;SAC/D,MAAM,CAAC,uBAAuB,EAAE,oDAAoD,CAAC;SACrF,MAAM,CAAC,WAAW,EAAE,yCAAyC,CAAC;SAC9D,MAAM,CAAC,SAAS,EAAE,gDAAgD,CAAC;SACnE,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC;SACjD,MAAM,CAAC,KAAK,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C;SAC1B,WAAW,CAAC,uDAAuD,CAAC;SACpE,MAAM,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;SAC/C,MAAM,CAAC,eAAe,EAAE,4CAA4C,CAAC;SACrE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;QAClC,MAAM,IAAA,gBAAU,EAAC,QAAQ,EAAE;YACzB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,iBAAiB;IACjB,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,0CAA0C,CAAC;SACvD,MAAM,CAAC,SAAS,EAAE,uDAAuD,CAAC;SAC1E,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,IAAA,sBAAa,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AAsC5D;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAqIf"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Create Command
|
|
4
4
|
*
|
|
5
5
|
* Creates a new Ketrics application from a template.
|
|
6
|
+
* Fetches templates from a remote repository by default, with local fallback.
|
|
6
7
|
*/
|
|
7
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
9
|
if (k2 === undefined) k2 = k;
|
|
@@ -42,6 +43,7 @@ exports.createCommand = createCommand;
|
|
|
42
43
|
const path = __importStar(require("path"));
|
|
43
44
|
const prompts_1 = require("@inquirer/prompts");
|
|
44
45
|
const logger_1 = require("../utils/logger");
|
|
46
|
+
const spinner_1 = require("../utils/spinner");
|
|
45
47
|
const template_service_1 = require("../services/template-service");
|
|
46
48
|
/**
|
|
47
49
|
* Prompt user to select a template interactively using arrow keys
|
|
@@ -77,6 +79,11 @@ function validateAppName(name) {
|
|
|
77
79
|
* Execute create command
|
|
78
80
|
*/
|
|
79
81
|
async function createCommand(appName, options) {
|
|
82
|
+
// Handle --clear-cache flag
|
|
83
|
+
if (options.clearCache) {
|
|
84
|
+
(0, template_service_1.clearCache)();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
80
87
|
// Validate app name
|
|
81
88
|
const nameValidation = validateAppName(appName);
|
|
82
89
|
if (!nameValidation.valid) {
|
|
@@ -84,9 +91,16 @@ async function createCommand(appName, options) {
|
|
|
84
91
|
process.exit(1);
|
|
85
92
|
}
|
|
86
93
|
// Get available templates
|
|
87
|
-
|
|
94
|
+
let templates;
|
|
95
|
+
try {
|
|
96
|
+
templates = await (0, spinner_1.withSpinner)('Fetching templates...', () => (0, template_service_1.getAvailableTemplates)({ refresh: options.refresh, local: options.local }), 'Templates loaded');
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
logger_1.logger.error(`Failed to load templates: ${error.message}`);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
88
102
|
if (templates.length === 0) {
|
|
89
|
-
logger_1.logger.error('No templates available.
|
|
103
|
+
logger_1.logger.error('No templates available.');
|
|
90
104
|
process.exit(1);
|
|
91
105
|
}
|
|
92
106
|
// Calculate destination path
|
|
@@ -100,7 +114,10 @@ async function createCommand(appName, options) {
|
|
|
100
114
|
let selectedTemplate;
|
|
101
115
|
if (options.template) {
|
|
102
116
|
// Use specified template
|
|
103
|
-
const template = (0, template_service_1.getTemplate)(options.template
|
|
117
|
+
const template = await (0, template_service_1.getTemplate)(options.template, {
|
|
118
|
+
refresh: options.refresh,
|
|
119
|
+
local: options.local,
|
|
120
|
+
});
|
|
104
121
|
if (!template) {
|
|
105
122
|
logger_1.logger.error(`Template not found: ${options.template}`);
|
|
106
123
|
logger_1.logger.newline();
|
|
@@ -128,11 +145,7 @@ async function createCommand(appName, options) {
|
|
|
128
145
|
logger_1.logger.newline();
|
|
129
146
|
logger_1.logger.info(`Creating '${appName}' with template: ${selectedTemplate.name}`);
|
|
130
147
|
logger_1.logger.newline();
|
|
131
|
-
|
|
132
|
-
logger_1.logger.log('Files to create:');
|
|
133
|
-
files.forEach((file) => logger_1.logger.file(`${appName}/${file}`));
|
|
134
|
-
logger_1.logger.newline();
|
|
135
|
-
// Create directory
|
|
148
|
+
// Create directory first so we can copy into it
|
|
136
149
|
try {
|
|
137
150
|
(0, template_service_1.createDirectory)(destDir);
|
|
138
151
|
}
|
|
@@ -140,20 +153,38 @@ async function createCommand(appName, options) {
|
|
|
140
153
|
logger_1.logger.error(`Failed to create directory: ${error.message}`);
|
|
141
154
|
process.exit(1);
|
|
142
155
|
}
|
|
143
|
-
// Copy template
|
|
156
|
+
// Copy template (download if remote)
|
|
157
|
+
let templateConfig;
|
|
144
158
|
try {
|
|
145
|
-
(0, template_service_1.
|
|
159
|
+
templateConfig = await (0, spinner_1.withSpinner)(`Downloading template '${selectedTemplate.name}'...`, () => (0, template_service_1.copyTemplateToDestination)(selectedTemplate, destDir), 'Template downloaded');
|
|
146
160
|
}
|
|
147
161
|
catch (error) {
|
|
162
|
+
// Clean up the created directory on failure
|
|
163
|
+
try {
|
|
164
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
165
|
+
fs.rmSync(destDir, { recursive: true, force: true });
|
|
166
|
+
}
|
|
167
|
+
catch { /* best effort */ }
|
|
148
168
|
logger_1.logger.error(`Failed to copy template: ${error.message}`);
|
|
149
169
|
process.exit(1);
|
|
150
170
|
}
|
|
151
|
-
//
|
|
171
|
+
// Show files that were created
|
|
172
|
+
const files = (0, template_service_1.getTemplateFiles)({
|
|
173
|
+
...selectedTemplate,
|
|
174
|
+
path: destDir,
|
|
175
|
+
source: 'local', // read from the destination dir now
|
|
176
|
+
});
|
|
177
|
+
if (files.length > 0) {
|
|
178
|
+
logger_1.logger.log('Files created:');
|
|
179
|
+
files.forEach((file) => logger_1.logger.file(`${appName}/${file}`));
|
|
180
|
+
logger_1.logger.newline();
|
|
181
|
+
}
|
|
182
|
+
// Apply customizations (app name replacement)
|
|
152
183
|
try {
|
|
153
|
-
(0, template_service_1.
|
|
184
|
+
(0, template_service_1.applyCustomizations)(destDir, appName, templateConfig);
|
|
154
185
|
}
|
|
155
186
|
catch (error) {
|
|
156
|
-
logger_1.logger.error(`Failed to
|
|
187
|
+
logger_1.logger.error(`Failed to customize template: ${error.message}`);
|
|
157
188
|
process.exit(1);
|
|
158
189
|
}
|
|
159
190
|
logger_1.logger.success(`Created '${appName}' successfully!`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDH,sCAwIC;AA/LD,2CAA6B;AAC7B,+CAA2C;AAC3C,4CAAyC;AACzC,8CAA+C;AAC/C,mEASsC;AAGtC;;GAEG;AACH,KAAK,UAAU,uBAAuB,CAAC,SAAyB;IAC9D,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,WAAW,EAAE;QACjD,KAA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AErD,kBAAkB;IAClB,eAAM,CAAC,OAAO,EAAE,CAAC;IACjB,eAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC1B,eAAM,CAAC,MAAM,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IAClC,eAAM,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC;IAC/C,eAAM,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC;IACjD,eAAM,CAAC,MAAM,CAAC,uDAAuD,CAAC,CAAC;IACvE,eAAM,CAAC,MAAM,CAAC,oDAAoD,CAAC,CAAC;IACpE,eAAM,CAAC,OAAO,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update Command
|
|
3
|
+
*
|
|
4
|
+
* Updates the Ketrics CLI to the latest version from npm.
|
|
5
|
+
*/
|
|
6
|
+
export interface UpdateOptions {
|
|
7
|
+
check?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Execute update command
|
|
11
|
+
*/
|
|
12
|
+
export declare function updateCommand(options?: UpdateOptions): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/update.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuE9E"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Update Command
|
|
4
|
+
*
|
|
5
|
+
* Updates the Ketrics CLI to the latest version from npm.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.updateCommand = updateCommand;
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const logger_1 = require("../utils/logger");
|
|
11
|
+
const spinner_1 = require("../utils/spinner");
|
|
12
|
+
const version_1 = require("../version");
|
|
13
|
+
const PACKAGE_NAME = '@ketrics/ketrics-cli';
|
|
14
|
+
/**
|
|
15
|
+
* Fetch the latest version from the npm registry
|
|
16
|
+
*/
|
|
17
|
+
async function getLatestVersion() {
|
|
18
|
+
const output = (0, child_process_1.execSync)(`npm view ${PACKAGE_NAME} version`, {
|
|
19
|
+
encoding: 'utf-8',
|
|
20
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
21
|
+
});
|
|
22
|
+
return output.trim();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Execute update command
|
|
26
|
+
*/
|
|
27
|
+
async function updateCommand(options = {}) {
|
|
28
|
+
const currentVersion = version_1.VERSION;
|
|
29
|
+
logger_1.logger.info(`Current version: ${currentVersion}`);
|
|
30
|
+
if (options.check) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
logger_1.logger.newline();
|
|
34
|
+
// Check for latest version
|
|
35
|
+
let latestVersion;
|
|
36
|
+
try {
|
|
37
|
+
latestVersion = await (0, spinner_1.withSpinner)('Checking for updates...', () => getLatestVersion(), 'Checked for updates');
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
logger_1.logger.error('Failed to check for updates. Ensure you have internet access and npm is installed.');
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
logger_1.logger.keyValue('Latest version', latestVersion);
|
|
44
|
+
logger_1.logger.newline();
|
|
45
|
+
// Compare versions
|
|
46
|
+
if (currentVersion === latestVersion) {
|
|
47
|
+
logger_1.logger.success('You are already on the latest version!');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Install latest version
|
|
51
|
+
logger_1.logger.info(`Updating ${currentVersion} → ${latestVersion}...`);
|
|
52
|
+
logger_1.logger.newline();
|
|
53
|
+
try {
|
|
54
|
+
await (0, spinner_1.withSpinner)('Installing latest version...', async () => {
|
|
55
|
+
(0, child_process_1.execSync)(`npm install -g ${PACKAGE_NAME}@latest`, {
|
|
56
|
+
encoding: 'utf-8',
|
|
57
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
58
|
+
});
|
|
59
|
+
}, 'Installed latest version');
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
63
|
+
if (message.includes('EACCES') || message.includes('permission')) {
|
|
64
|
+
logger_1.logger.error('Permission denied. Try running with sudo:');
|
|
65
|
+
logger_1.logger.newline();
|
|
66
|
+
logger_1.logger.indent(`sudo npm install -g ${PACKAGE_NAME}@latest`, 1);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
logger_1.logger.error('Failed to update. You can try manually:');
|
|
70
|
+
logger_1.logger.newline();
|
|
71
|
+
logger_1.logger.indent(`npm install -g ${PACKAGE_NAME}@latest`, 1);
|
|
72
|
+
}
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
logger_1.logger.newline();
|
|
76
|
+
logger_1.logger.success(`Successfully updated to v${latestVersion}!`);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/update.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AA2BH,sCAuEC;AAhGD,iDAAyC;AACzC,4CAAyC;AACzC,8CAA+C;AAC/C,wCAAqC;AAErC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAE5C;;GAEG;AACH,KAAK,UAAU,gBAAgB;IAC7B,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,YAAY,YAAY,UAAU,EAAE;QAC1D,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;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C;QACL,CAAC,EACD,0BAA0B,CAC3B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAEzD,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YACjE,eAAM,CAAC,KAAK,CACV,2CAA2C,CAC5C,CAAC;YACF,eAAM,CAAC,OAAO,EAAE,CAAC;YACjB,eAAM,CAAC,MAAM,CAAC,uBAAuB,YAAY,SAAS,EAAE,CAAC,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,eAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;YACxD,eAAM,CAAC,OAAO,EAAE,CAAC;YACjB,eAAM,CAAC,MAAM,CAAC,kBAAkB,YAAY,SAAS,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,eAAM,CAAC,OAAO,EAAE,CAAC;IACjB,eAAM,CAAC,OAAO,CAAC,4BAA4B,aAAa,GAAG,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Template Service
|
|
3
|
+
*
|
|
4
|
+
* Handles discovery and copying of bundled templates shipped with the CLI.
|
|
5
|
+
* Used as fallback when remote templates are unavailable.
|
|
6
|
+
*/
|
|
7
|
+
import type { TemplateInfo } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Get list of available templates
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAvailableTemplates(): TemplateInfo[];
|
|
12
|
+
/**
|
|
13
|
+
* Get a specific template by name
|
|
14
|
+
*/
|
|
15
|
+
export declare function getTemplate(name: string): TemplateInfo | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Validation result for destination directory
|
|
18
|
+
*/
|
|
19
|
+
export interface DestinationValidation {
|
|
20
|
+
valid: boolean;
|
|
21
|
+
errors: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Validate destination directory before copying template
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateDestination(destDir: string): DestinationValidation;
|
|
27
|
+
/**
|
|
28
|
+
* Copy template to destination directory
|
|
29
|
+
*/
|
|
30
|
+
export declare function copyTemplate(template: TemplateInfo, destDir: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get files that will be copied from template
|
|
33
|
+
*/
|
|
34
|
+
export declare function getTemplateFiles(template: TemplateInfo): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Update app name in project files
|
|
37
|
+
*
|
|
38
|
+
* Updates the name field in:
|
|
39
|
+
* - ketrics.config.json
|
|
40
|
+
* - frontend/package.json
|
|
41
|
+
* - backend/package.json
|
|
42
|
+
*/
|
|
43
|
+
export declare function updateAppName(projectDir: string, appName: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a directory exists
|
|
46
|
+
*/
|
|
47
|
+
export declare function directoryExists(dirPath: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Create a directory
|
|
50
|
+
*/
|
|
51
|
+
export declare function createDirectory(dirPath: string): void;
|
|
52
|
+
//# sourceMappingURL=local-template-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-template-service.d.ts","sourceRoot":"","sources":["../../../src/services/local-template-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAqB7C;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,YAAY,EAAE,CAgCtD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAGlE;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAsB1E;AAyBD;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,EAAE,CAoBjE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAmBvE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAErD"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Local Template Service
|
|
4
|
+
*
|
|
5
|
+
* Handles discovery and copying of bundled templates shipped with the CLI.
|
|
6
|
+
* Used as fallback when remote templates are unavailable.
|
|
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.getAvailableTemplates = getAvailableTemplates;
|
|
43
|
+
exports.getTemplate = getTemplate;
|
|
44
|
+
exports.validateDestination = validateDestination;
|
|
45
|
+
exports.copyTemplate = copyTemplate;
|
|
46
|
+
exports.getTemplateFiles = getTemplateFiles;
|
|
47
|
+
exports.updateAppName = updateAppName;
|
|
48
|
+
exports.directoryExists = directoryExists;
|
|
49
|
+
exports.createDirectory = createDirectory;
|
|
50
|
+
const fs = __importStar(require("fs"));
|
|
51
|
+
const path = __importStar(require("path"));
|
|
52
|
+
/**
|
|
53
|
+
* Get the templates directory path
|
|
54
|
+
*/
|
|
55
|
+
function getTemplatesDir() {
|
|
56
|
+
// When running from dist/, templates is at ../templates
|
|
57
|
+
// When running from src/, templates is at ../../templates
|
|
58
|
+
const distPath = path.join(__dirname, '../../templates');
|
|
59
|
+
const srcPath = path.join(__dirname, '../../../templates');
|
|
60
|
+
if (fs.existsSync(distPath)) {
|
|
61
|
+
return distPath;
|
|
62
|
+
}
|
|
63
|
+
if (fs.existsSync(srcPath)) {
|
|
64
|
+
return srcPath;
|
|
65
|
+
}
|
|
66
|
+
throw new Error('Templates directory not found');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get list of available templates
|
|
70
|
+
*/
|
|
71
|
+
function getAvailableTemplates() {
|
|
72
|
+
const templatesDir = getTemplatesDir();
|
|
73
|
+
const templates = [];
|
|
74
|
+
const entries = fs.readdirSync(templatesDir, { withFileTypes: true });
|
|
75
|
+
for (const entry of entries) {
|
|
76
|
+
if (!entry.isDirectory())
|
|
77
|
+
continue;
|
|
78
|
+
const templatePath = path.join(templatesDir, entry.name);
|
|
79
|
+
const configPath = path.join(templatePath, 'ketrics.config.json');
|
|
80
|
+
// Skip if no ketrics.config.json
|
|
81
|
+
if (!fs.existsSync(configPath))
|
|
82
|
+
continue;
|
|
83
|
+
try {
|
|
84
|
+
const configContent = fs.readFileSync(configPath, 'utf-8');
|
|
85
|
+
const config = JSON.parse(configContent);
|
|
86
|
+
templates.push({
|
|
87
|
+
name: entry.name,
|
|
88
|
+
path: templatePath,
|
|
89
|
+
description: config.description || 'No description available',
|
|
90
|
+
source: 'local',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Skip templates with invalid config
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return templates;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get a specific template by name
|
|
102
|
+
*/
|
|
103
|
+
function getTemplate(name) {
|
|
104
|
+
const templates = getAvailableTemplates();
|
|
105
|
+
return templates.find((t) => t.name === name);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Validate destination directory before copying template
|
|
109
|
+
*/
|
|
110
|
+
function validateDestination(destDir) {
|
|
111
|
+
const errors = [];
|
|
112
|
+
// Check for ketrics.config.json
|
|
113
|
+
if (fs.existsSync(path.join(destDir, 'ketrics.config.json'))) {
|
|
114
|
+
errors.push('Cannot initialize: ketrics.config.json already exists in this directory');
|
|
115
|
+
}
|
|
116
|
+
// Check for frontend/ directory
|
|
117
|
+
if (fs.existsSync(path.join(destDir, 'frontend'))) {
|
|
118
|
+
errors.push('Cannot initialize: frontend/ directory already exists');
|
|
119
|
+
}
|
|
120
|
+
// Check for backend/ directory
|
|
121
|
+
if (fs.existsSync(path.join(destDir, 'backend'))) {
|
|
122
|
+
errors.push('Cannot initialize: backend/ directory already exists');
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
valid: errors.length === 0,
|
|
126
|
+
errors,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Copy directory recursively
|
|
131
|
+
*/
|
|
132
|
+
function copyDirRecursive(src, dest) {
|
|
133
|
+
// Create destination directory
|
|
134
|
+
if (!fs.existsSync(dest)) {
|
|
135
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
136
|
+
}
|
|
137
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
138
|
+
for (const entry of entries) {
|
|
139
|
+
const srcPath = path.join(src, entry.name);
|
|
140
|
+
const destPath = path.join(dest, entry.name);
|
|
141
|
+
if (entry.isDirectory()) {
|
|
142
|
+
copyDirRecursive(srcPath, destPath);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
fs.copyFileSync(srcPath, destPath);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Copy template to destination directory
|
|
151
|
+
*/
|
|
152
|
+
function copyTemplate(template, destDir) {
|
|
153
|
+
copyDirRecursive(template.path, destDir);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get files that will be copied from template
|
|
157
|
+
*/
|
|
158
|
+
function getTemplateFiles(template) {
|
|
159
|
+
const files = [];
|
|
160
|
+
function collectFiles(dir, relativePath = '') {
|
|
161
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
162
|
+
for (const entry of entries) {
|
|
163
|
+
const fullPath = path.join(dir, entry.name);
|
|
164
|
+
const relPath = relativePath ? path.join(relativePath, entry.name) : entry.name;
|
|
165
|
+
if (entry.isDirectory()) {
|
|
166
|
+
collectFiles(fullPath, relPath);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
files.push(relPath);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
collectFiles(template.path);
|
|
174
|
+
return files;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Update app name in project files
|
|
178
|
+
*
|
|
179
|
+
* Updates the name field in:
|
|
180
|
+
* - ketrics.config.json
|
|
181
|
+
* - frontend/package.json
|
|
182
|
+
* - backend/package.json
|
|
183
|
+
*/
|
|
184
|
+
function updateAppName(projectDir, appName) {
|
|
185
|
+
const filesToUpdate = [
|
|
186
|
+
{ path: path.join(projectDir, 'ketrics.config.json'), field: 'name' },
|
|
187
|
+
{ path: path.join(projectDir, 'frontend', 'package.json'), field: 'name' },
|
|
188
|
+
{ path: path.join(projectDir, 'backend', 'package.json'), field: 'name' },
|
|
189
|
+
];
|
|
190
|
+
for (const file of filesToUpdate) {
|
|
191
|
+
if (!fs.existsSync(file.path))
|
|
192
|
+
continue;
|
|
193
|
+
try {
|
|
194
|
+
const content = fs.readFileSync(file.path, 'utf-8');
|
|
195
|
+
const json = JSON.parse(content);
|
|
196
|
+
json[file.field] = appName;
|
|
197
|
+
fs.writeFileSync(file.path, JSON.stringify(json, null, 2) + '\n', 'utf-8');
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
// Skip files that can't be parsed
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Check if a directory exists
|
|
206
|
+
*/
|
|
207
|
+
function directoryExists(dirPath) {
|
|
208
|
+
return fs.existsSync(dirPath);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Create a directory
|
|
212
|
+
*/
|
|
213
|
+
function createDirectory(dirPath) {
|
|
214
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=local-template-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-template-service.js","sourceRoot":"","sources":["../../../src/services/local-template-service.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BH,sDAgCC;AAKD,kCAGC;AAaD,kDAsBC;AA4BD,oCAEC;AAKD,4CAoBC;AAUD,sCAmBC;AAKD,0CAEC;AAKD,0CAEC;AAvMD,uCAAyB;AACzB,2CAA6B;AAG7B;;GAEG;AACH,SAAS,eAAe;IACtB,wDAAwD;IACxD,0DAA0D;IAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;IAE3D,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB;IACnC,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,MAAM,SAAS,GAAmB,EAAE,CAAC;IAErC,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtE,KAAK,MAAM,KAAK,IAAI,OA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U,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;QAC1E,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,cAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;KAC1E,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,SAAS;QAExC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACpD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;YAC3B,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7E,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,OAAe;IAC7C,OAAO,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,OAAe;IAC7C,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Template Service
|
|
3
|
+
*
|
|
4
|
+
* Fetches templates from the public ketrics-application-templates GitHub repository.
|
|
5
|
+
* Uses GitHub tarball download for efficient single-request fetching.
|
|
6
|
+
*/
|
|
7
|
+
import type { TemplateManifest, TemplateManifestEntry, TemplateInfo, TemplateConfig } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Fetch the templates.json manifest from the remote repository
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchManifest(): Promise<TemplateManifest>;
|
|
12
|
+
/**
|
|
13
|
+
* Download and extract the repo tarball to a temporary directory.
|
|
14
|
+
* Returns the path to the extracted repo root.
|
|
15
|
+
*/
|
|
16
|
+
export declare function downloadAndExtractTarball(): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Extract a specific template from the downloaded repo to a destination directory.
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractTemplate(repoDir: string, templateEntry: TemplateManifestEntry, destDir: string, ignorePatterns?: string[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Read template.json config from a template directory
|
|
23
|
+
*/
|
|
24
|
+
export declare function readTemplateConfig(templateDir: string): TemplateConfig | null;
|
|
25
|
+
/**
|
|
26
|
+
* Apply placeholders defined in template.json
|
|
27
|
+
*/
|
|
28
|
+
export declare function applyPlaceholders(projectDir: string, templateConfig: TemplateConfig, values: Record<string, string>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Convert manifest entries to TemplateInfo objects for display
|
|
31
|
+
*/
|
|
32
|
+
export declare function manifestToTemplateInfos(manifest: TemplateManifest, basePath: string): TemplateInfo[];
|
|
33
|
+
/**
|
|
34
|
+
* Get files that will be copied from a directory (for display)
|
|
35
|
+
*/
|
|
36
|
+
export declare function getTemplateFilesFromDir(templateDir: string, ignorePatterns?: string[]): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Clean up temporary directory
|
|
39
|
+
*/
|
|
40
|
+
export declare function cleanupTmpDir(tmpDir: string): void;
|
|
41
|
+
//# sourceMappingURL=remote-template-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-template-service.d.ts","sourceRoot":"","sources":["../../../src/services/remote-template-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAUtG;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAgB/D;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC,CA6BjE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,qBAAqB,EACpC,OAAO,EAAE,MAAM,EACf,cAAc,GAAE,MAAM,EAAO,GAC5B,IAAI,CAQN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAY7E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,IAAI,CAqBN;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,MAAM,GACf,YAAY,EAAE,CAUhB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,MAAM,EAAO,GAC5B,MAAM,EAAE,CAqBV;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMlD"}
|