@tbsten/mir 0.0.2-alpha07 → 0.0.2-alpha08
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/cli.js +35 -164
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5868,8 +5868,8 @@ var require_lib = __commonJS({
|
|
|
5868
5868
|
handlebars.print = printer.print;
|
|
5869
5869
|
module.exports = handlebars;
|
|
5870
5870
|
function extension(module2, filename) {
|
|
5871
|
-
var
|
|
5872
|
-
var templateString =
|
|
5871
|
+
var fs16 = __require("fs");
|
|
5872
|
+
var templateString = fs16.readFileSync(filename, "utf8");
|
|
5873
5873
|
module2.exports = handlebars.compile(templateString);
|
|
5874
5874
|
}
|
|
5875
5875
|
if (typeof __require !== "undefined" && __require.extensions) {
|
|
@@ -5908,7 +5908,7 @@ var ja = {
|
|
|
5908
5908
|
"error.safe-mode-overwrite": "safe \u30E2\u30FC\u30C9\u3067\u306F\u65E2\u5B58\u30D5\u30A1\u30A4\u30EB\u306E\u4E0A\u66F8\u304D\u306F\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {path}",
|
|
5909
5909
|
"error.file-not-found": '\u30D5\u30A1\u30A4\u30EB "{path}" \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093',
|
|
5910
5910
|
"error.file-read-failed": '\u30D5\u30A1\u30A4\u30EB "{path}" \u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F',
|
|
5911
|
-
"error.snippet-not-found-details": "\n\u53EF\u80FD\u306A\u539F\u56E0:\n1. Snippet \u540D\u306E\u5165\u529B\u30DF\u30B9\n2. Registry \u306B\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3044\n3. Registry \u3078\u306E\u30A2\u30AF\u30BB\u30B9\u6A29\u9650\u304C\u306A\u3044\n\n\u78BA\u8A8D\u65B9\u6CD5:\n\u2022 mir list
|
|
5911
|
+
"error.snippet-not-found-details": "\n\u53EF\u80FD\u306A\u539F\u56E0:\n1. Snippet \u540D\u306E\u5165\u529B\u30DF\u30B9\n2. Registry \u306B\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3044\n3. Registry \u3078\u306E\u30A2\u30AF\u30BB\u30B9\u6A29\u9650\u304C\u306A\u3044\n\n\u78BA\u8A8D\u65B9\u6CD5:\n\u2022 mir list - \u5229\u7528\u53EF\u80FD\u306A snippet \u3092\u8868\u793A\n\u2022 mir info <name> - snippet \u306E\u8A73\u7D30\u60C5\u5831\u3092\u8868\u793A",
|
|
5912
5912
|
// create
|
|
5913
5913
|
"create.success": 'Snippet "{name}" \u3092\u4F5C\u6210\u3057\u307E\u3057\u305F',
|
|
5914
5914
|
// publish
|
|
@@ -5930,9 +5930,6 @@ var ja = {
|
|
|
5930
5930
|
// sync
|
|
5931
5931
|
"sync.no-new-vars": "\u8FFD\u52A0\u3059\u308B\u5909\u6570\u306F\u3042\u308A\u307E\u305B\u3093",
|
|
5932
5932
|
"sync.success": "{count} \u4EF6\u306E\u5909\u6570\u3092\u8FFD\u52A0\u3057\u307E\u3057\u305F",
|
|
5933
|
-
// search
|
|
5934
|
-
"search.query-required": "\u691C\u7D22\u30AD\u30FC\u30EF\u30FC\u30C9\u304C\u5FC5\u8981\u3067\u3059",
|
|
5935
|
-
"search.no-results": '"{query}" \u306B\u4E00\u81F4\u3059\u308B snippet \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093',
|
|
5936
5933
|
// error specific
|
|
5937
5934
|
"error.no-failed-snippets": "\u5931\u6557\u3057\u305F snippet \u306E\u5C65\u6B74\u304C\u3042\u308A\u307E\u305B\u3093",
|
|
5938
5935
|
"error.publish-token-required": "\u30EA\u30E2\u30FC\u30C8 registry \u3078\u306E publish \u306B\u306F publish_token \u304C\u5FC5\u8981\u3067\u3059\u3002~/.mir/mirconfig.yaml \u3067\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
@@ -5998,7 +5995,7 @@ var en = {
|
|
|
5998
5995
|
"error.safe-mode-overwrite": "Overwriting existing files is not allowed in safe mode: {path}",
|
|
5999
5996
|
"error.file-not-found": 'File "{path}" not found',
|
|
6000
5997
|
"error.file-read-failed": 'Failed to read file "{path}"',
|
|
6001
|
-
"error.snippet-not-found-details": "\nPossible causes:\n1. Typo in snippet name\n2. Snippet not registered in registry\n3. No access permission to registry\n\nWays to check:\n\u2022 mir list
|
|
5998
|
+
"error.snippet-not-found-details": "\nPossible causes:\n1. Typo in snippet name\n2. Snippet not registered in registry\n3. No access permission to registry\n\nWays to check:\n\u2022 mir list - Show available snippets\n\u2022 mir info <name> - Show snippet details",
|
|
6002
5999
|
// create
|
|
6003
6000
|
"create.success": 'Created snippet "{name}"',
|
|
6004
6001
|
// publish
|
|
@@ -6020,9 +6017,6 @@ var en = {
|
|
|
6020
6017
|
// sync
|
|
6021
6018
|
"sync.no-new-vars": "No new variables to add",
|
|
6022
6019
|
"sync.success": "Added {count} variable(s)",
|
|
6023
|
-
// search
|
|
6024
|
-
"search.query-required": "Search query is required",
|
|
6025
|
-
"search.no-results": 'No snippets found matching "{query}"',
|
|
6026
6020
|
// error specific
|
|
6027
6021
|
"error.no-failed-snippets": "No failed snippet history",
|
|
6028
6022
|
"error.publish-token-required": "publish_token is required to publish to remote registry. Configure it in ~/.mir/mirconfig.yaml",
|
|
@@ -6819,7 +6813,7 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
6819
6813
|
|
|
6820
6814
|
// ../mir-core/dist/generated/validate-mirconfig.js
|
|
6821
6815
|
var validate_mirconfig_default = validate102;
|
|
6822
|
-
var schema11 = { "$id": "https://raw.githubusercontent.com/TBSten/mir/refs/heads/main/schema/v1/mirconfig.schema.json", "title": "mir global configuration", "description": "mir \u306E\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\uFF08~/.mir/config.yaml \u307E\u305F\u306F .mir/config.yaml\uFF09\u306E\u30B9\u30AD\u30FC\u30DE", "type": "object", "additionalProperties": false, "properties": { "registries": { "type": "array", "description": "registry \u306E\u4E00\u89A7\u3002\u5B9A\u7FA9\u9806\u306B\u691C\u7D22\u3055\u308C\u308B", "items": { "$ref": "#/$defs/registryEntry" }, "default": [{ "path": "~/.mir/registry" }] }, "locale": { "type": "string", "description": "CLI \u306E\u8868\u793A\u8A00\u8A9E", "enum": ["ja", "en"], "default": "ja" }, "defaults": { "type": "object", "description": "
|
|
6816
|
+
var schema11 = { "$id": "https://raw.githubusercontent.com/TBSten/mir/refs/heads/main/schema/v1/mirconfig.schema.json", "title": "mir global configuration", "description": "mir \u306E\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\uFF08~/.mir/config.yaml \u307E\u305F\u306F .mir/config.yaml\uFF09\u306E\u30B9\u30AD\u30FC\u30DE", "type": "object", "additionalProperties": false, "properties": { "registries": { "type": "array", "description": "registry \u306E\u4E00\u89A7\u3002\u5B9A\u7FA9\u9806\u306B\u691C\u7D22\u3055\u308C\u308B", "items": { "$ref": "#/$defs/registryEntry" }, "default": [{ "path": "~/.mir/registry" }] }, "locale": { "type": "string", "description": "CLI \u306E\u8868\u793A\u8A00\u8A9E", "enum": ["ja", "en"], "default": "ja" }, "defaults": { "type": "object", "description": "\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u3002\u4EFB\u610F\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u5909\u6570\u540D\u3092\u30AD\u30FC\u3068\u3057\u3066\u8A2D\u5B9A\u53EF\u80FD", "additionalProperties": { "type": "string" }, "properties": { "author": { "type": "string", "description": "snippet \u4F5C\u6210\u6642\u306E\u30C7\u30D5\u30A9\u30EB\u30C8 author" } } } }, "$defs": { "registryEntry": { "type": "object", "description": "registry \u306E\u5B9A\u7FA9\u3002path\uFF08\u30ED\u30FC\u30AB\u30EB\uFF09\u307E\u305F\u306F url\uFF08\u30EA\u30E2\u30FC\u30C8\uFF09\u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3059\u308B", "additionalProperties": false, "properties": { "name": { "type": "string", "description": "registry \u306E\u8B58\u5225\u540D\u3002--registry \u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u6307\u5B9A\u3059\u308B\u969B\u306B\u4F7F\u7528" }, "path": { "type": "string", "description": "\u30ED\u30FC\u30AB\u30EB registry \u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u30D1\u30B9\u3002url \u3068\u6392\u4ED6" }, "url": { "type": "string", "format": "uri", "description": "\u30EA\u30E2\u30FC\u30C8 registry \u306E URL\u3002path \u3068\u6392\u4ED6\u3002\u8AAD\u307F\u53D6\u308A\u5C02\u7528", "pattern": "^https?://" }, "publish_token": { "type": "string", "description": "\u30EA\u30E2\u30FC\u30C8 registry \u3078\u306E publish \u7528 API \u30C8\u30FC\u30AF\u30F3\u3002mir login \u30B3\u30DE\u30F3\u30C9\u3067\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u308B" } }, "oneOf": [{ "required": ["path"], "not": { "required": ["url"] } }, { "required": ["url"], "not": { "required": ["path"] } }] } } };
|
|
6823
6817
|
var pattern02 = new RegExp("^https?://", "u");
|
|
6824
6818
|
function validate102(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
6825
6819
|
;
|
|
@@ -7082,13 +7076,15 @@ function validate102(data, { instancePath = "", parentData, parentDataProperty,
|
|
|
7082
7076
|
if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
|
|
7083
7077
|
for (const key2 in data7) {
|
|
7084
7078
|
if (!(key2 === "author")) {
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
vErrors
|
|
7088
|
-
|
|
7089
|
-
|
|
7079
|
+
if (typeof data7[key2] !== "string") {
|
|
7080
|
+
const err18 = { instancePath: instancePath + "/defaults/" + key2.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/defaults/additionalProperties/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
7081
|
+
if (vErrors === null) {
|
|
7082
|
+
vErrors = [err18];
|
|
7083
|
+
} else {
|
|
7084
|
+
vErrors.push(err18);
|
|
7085
|
+
}
|
|
7086
|
+
errors++;
|
|
7090
7087
|
}
|
|
7091
|
-
errors++;
|
|
7092
7088
|
}
|
|
7093
7089
|
}
|
|
7094
7090
|
if (data7.author !== void 0) {
|
|
@@ -9396,132 +9392,8 @@ function parseVariableArgs2(args) {
|
|
|
9396
9392
|
return result;
|
|
9397
9393
|
}
|
|
9398
9394
|
|
|
9399
|
-
// src/commands/search.ts
|
|
9400
|
-
import fs13 from "fs";
|
|
9401
|
-
async function searchSnippets(query, opts2 = {}) {
|
|
9402
|
-
if (!query) {
|
|
9403
|
-
if (!opts2.quiet) {
|
|
9404
|
-
warn(t("search.query-required"));
|
|
9405
|
-
}
|
|
9406
|
-
return;
|
|
9407
|
-
}
|
|
9408
|
-
const config = loadMirConfig();
|
|
9409
|
-
const registries = resolveInstallRegistries(config, opts2.registry);
|
|
9410
|
-
if (registries.length === 0) {
|
|
9411
|
-
if (!opts2.quiet) {
|
|
9412
|
-
warn(t("error.no-snippets"));
|
|
9413
|
-
}
|
|
9414
|
-
return;
|
|
9415
|
-
}
|
|
9416
|
-
if (opts2.json || opts2.yaml) {
|
|
9417
|
-
const resultList = [];
|
|
9418
|
-
for (const entry of registries) {
|
|
9419
|
-
if (entry.url) {
|
|
9420
|
-
const result = {
|
|
9421
|
-
name: entry.name ?? "remote",
|
|
9422
|
-
type: "remote",
|
|
9423
|
-
url: entry.url,
|
|
9424
|
-
snippets: []
|
|
9425
|
-
};
|
|
9426
|
-
try {
|
|
9427
|
-
const allSnippets = await listRemoteSnippets(resolveRegistryUrl(entry));
|
|
9428
|
-
const lowerQuery = query.toLowerCase();
|
|
9429
|
-
result.snippets = allSnippets.filter(
|
|
9430
|
-
(name) => name.toLowerCase().includes(lowerQuery)
|
|
9431
|
-
);
|
|
9432
|
-
} catch {
|
|
9433
|
-
}
|
|
9434
|
-
resultList.push(result);
|
|
9435
|
-
} else if (entry.path) {
|
|
9436
|
-
const regPath = resolveRegistryPath(entry);
|
|
9437
|
-
const result = {
|
|
9438
|
-
name: entry.name ?? "local",
|
|
9439
|
-
type: "local",
|
|
9440
|
-
path: regPath,
|
|
9441
|
-
snippets: []
|
|
9442
|
-
};
|
|
9443
|
-
if (fs13.existsSync(regPath)) {
|
|
9444
|
-
try {
|
|
9445
|
-
const allSnippets = listRegistrySnippets(regPath);
|
|
9446
|
-
const lowerQuery = query.toLowerCase();
|
|
9447
|
-
result.snippets = allSnippets.filter(
|
|
9448
|
-
(name) => name.toLowerCase().includes(lowerQuery)
|
|
9449
|
-
);
|
|
9450
|
-
} catch {
|
|
9451
|
-
}
|
|
9452
|
-
}
|
|
9453
|
-
resultList.push(result);
|
|
9454
|
-
}
|
|
9455
|
-
}
|
|
9456
|
-
infoForOutput({ query, results: resultList });
|
|
9457
|
-
return;
|
|
9458
|
-
}
|
|
9459
|
-
let foundAny = false;
|
|
9460
|
-
for (const entry of registries) {
|
|
9461
|
-
if (entry.url) {
|
|
9462
|
-
try {
|
|
9463
|
-
const allSnippets = await listRemoteSnippets(entry.url);
|
|
9464
|
-
const lowerQuery = query.toLowerCase();
|
|
9465
|
-
const searchResults = allSnippets.filter(
|
|
9466
|
-
(name) => name.toLowerCase().includes(lowerQuery)
|
|
9467
|
-
);
|
|
9468
|
-
if (searchResults.length > 0) {
|
|
9469
|
-
if (!opts2.quiet) {
|
|
9470
|
-
step(`${entry.name ?? "remote"} (${entry.url}):`);
|
|
9471
|
-
for (const name of searchResults) {
|
|
9472
|
-
fileItem(name);
|
|
9473
|
-
}
|
|
9474
|
-
}
|
|
9475
|
-
foundAny = true;
|
|
9476
|
-
}
|
|
9477
|
-
} catch {
|
|
9478
|
-
if (!opts2.quiet) {
|
|
9479
|
-
warn(` (\u691C\u7D22\u5931\u6557: ${entry.name ?? entry.url})`);
|
|
9480
|
-
}
|
|
9481
|
-
}
|
|
9482
|
-
} else if (entry.path) {
|
|
9483
|
-
const regPath = resolveRegistryPath(entry);
|
|
9484
|
-
if (fs13.existsSync(regPath)) {
|
|
9485
|
-
try {
|
|
9486
|
-
const allSnippets = listRegistrySnippets(regPath);
|
|
9487
|
-
const lowerQuery = query.toLowerCase();
|
|
9488
|
-
const searchResults = allSnippets.filter(
|
|
9489
|
-
(name) => name.toLowerCase().includes(lowerQuery)
|
|
9490
|
-
);
|
|
9491
|
-
if (searchResults.length > 0) {
|
|
9492
|
-
if (!opts2.quiet) {
|
|
9493
|
-
step(`${entry.name ?? "local"} (${regPath}):`);
|
|
9494
|
-
for (const name of searchResults) {
|
|
9495
|
-
fileItem(name);
|
|
9496
|
-
}
|
|
9497
|
-
}
|
|
9498
|
-
foundAny = true;
|
|
9499
|
-
}
|
|
9500
|
-
} catch {
|
|
9501
|
-
if (!opts2.quiet) {
|
|
9502
|
-
warn(` (\u8AAD\u307F\u8FBC\u307F\u5931\u6557)`);
|
|
9503
|
-
}
|
|
9504
|
-
}
|
|
9505
|
-
}
|
|
9506
|
-
}
|
|
9507
|
-
}
|
|
9508
|
-
if (!foundAny && !opts2.quiet) {
|
|
9509
|
-
warn(t("search.no-results", { query }));
|
|
9510
|
-
}
|
|
9511
|
-
}
|
|
9512
|
-
function registerSearchCommand(program2) {
|
|
9513
|
-
program2.command("search <query>").alias("q").description("snippet \u3092\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22\u3059\u308B").option("-r, --registry <name>", "\u691C\u7D22\u5BFE\u8C61 registry \u306E\u540D\u524D").option("--json", "JSON \u5F62\u5F0F\u3067\u51FA\u529B").option("--yaml", "YAML \u5F62\u5F0F\u3067\u51FA\u529B").option("--quiet", "\u30ED\u30B0\u51FA\u529B\u3092\u6291\u5236").action(async (query, opts2) => {
|
|
9514
|
-
await searchSnippets(query, opts2);
|
|
9515
|
-
}).addHelpText("after", `
|
|
9516
|
-
Examples:
|
|
9517
|
-
mir search react
|
|
9518
|
-
mir search component --registry custom
|
|
9519
|
-
mir search hook --json
|
|
9520
|
-
mir search template --quiet`);
|
|
9521
|
-
}
|
|
9522
|
-
|
|
9523
9395
|
// src/commands/clone.ts
|
|
9524
|
-
import
|
|
9396
|
+
import fs13 from "fs";
|
|
9525
9397
|
import path9 from "path";
|
|
9526
9398
|
import yaml5 from "js-yaml";
|
|
9527
9399
|
function generateCloneName(originalName) {
|
|
@@ -9530,7 +9402,7 @@ function generateCloneName(originalName) {
|
|
|
9530
9402
|
function cloneSnippet(name, opts2 = {}, cwd = process.cwd()) {
|
|
9531
9403
|
validateSnippetName(name);
|
|
9532
9404
|
const sourceYamlPath = snippetYamlPath(cwd, name);
|
|
9533
|
-
if (!
|
|
9405
|
+
if (!fs13.existsSync(sourceYamlPath)) {
|
|
9534
9406
|
throw new SnippetNotFoundError(name);
|
|
9535
9407
|
}
|
|
9536
9408
|
const sourceDirPath = snippetDirPath(cwd, name);
|
|
@@ -9538,45 +9410,45 @@ function cloneSnippet(name, opts2 = {}, cwd = process.cwd()) {
|
|
|
9538
9410
|
validateSnippetName(cloneName);
|
|
9539
9411
|
const targetYamlPath = snippetYamlPath(cwd, cloneName);
|
|
9540
9412
|
const targetDirPath = snippetDirPath(cwd, cloneName);
|
|
9541
|
-
if (
|
|
9413
|
+
if (fs13.existsSync(targetYamlPath)) {
|
|
9542
9414
|
if (!opts2.force) {
|
|
9543
9415
|
throw new SnippetAlreadyExistsError(cloneName);
|
|
9544
9416
|
}
|
|
9545
|
-
|
|
9546
|
-
if (
|
|
9547
|
-
|
|
9417
|
+
fs13.rmSync(targetYamlPath, { force: true });
|
|
9418
|
+
if (fs13.existsSync(targetDirPath)) {
|
|
9419
|
+
fs13.rmSync(targetDirPath, { recursive: true, force: true });
|
|
9548
9420
|
}
|
|
9549
9421
|
}
|
|
9550
9422
|
const basePath = snippetsBasePath(cwd);
|
|
9551
|
-
|
|
9552
|
-
const sourceContent =
|
|
9423
|
+
fs13.mkdirSync(basePath, { recursive: true });
|
|
9424
|
+
const sourceContent = fs13.readFileSync(sourceYamlPath, "utf-8");
|
|
9553
9425
|
const sourceDef = yaml5.load(sourceContent);
|
|
9554
9426
|
const targetDef = {
|
|
9555
9427
|
...sourceDef,
|
|
9556
9428
|
name: cloneName
|
|
9557
9429
|
};
|
|
9558
9430
|
const targetContent = serializeSnippetYaml(targetDef);
|
|
9559
|
-
|
|
9560
|
-
if (
|
|
9561
|
-
|
|
9431
|
+
fs13.writeFileSync(targetYamlPath, targetContent, "utf-8");
|
|
9432
|
+
if (fs13.existsSync(sourceDirPath)) {
|
|
9433
|
+
fs13.mkdirSync(targetDirPath, { recursive: true });
|
|
9562
9434
|
copyDirRecursive(sourceDirPath, targetDirPath);
|
|
9563
9435
|
} else {
|
|
9564
|
-
|
|
9436
|
+
fs13.mkdirSync(targetDirPath, { recursive: true });
|
|
9565
9437
|
}
|
|
9566
9438
|
success(t("clone.success", { name, alias: cloneName }));
|
|
9567
9439
|
fileItem(path9.relative(cwd, targetYamlPath));
|
|
9568
9440
|
dirItem(`${path9.relative(cwd, targetDirPath)}/`);
|
|
9569
9441
|
}
|
|
9570
9442
|
function copyDirRecursive(src, dest) {
|
|
9571
|
-
const entries =
|
|
9443
|
+
const entries = fs13.readdirSync(src, { withFileTypes: true });
|
|
9572
9444
|
for (const entry of entries) {
|
|
9573
9445
|
const srcPath = path9.join(src, entry.name);
|
|
9574
9446
|
const destPath = path9.join(dest, entry.name);
|
|
9575
9447
|
if (entry.isDirectory()) {
|
|
9576
|
-
|
|
9448
|
+
fs13.mkdirSync(destPath, { recursive: true });
|
|
9577
9449
|
copyDirRecursive(srcPath, destPath);
|
|
9578
9450
|
} else {
|
|
9579
|
-
|
|
9451
|
+
fs13.copyFileSync(srcPath, destPath);
|
|
9580
9452
|
}
|
|
9581
9453
|
}
|
|
9582
9454
|
}
|
|
@@ -9593,7 +9465,7 @@ Examples:
|
|
|
9593
9465
|
|
|
9594
9466
|
// src/commands/login.ts
|
|
9595
9467
|
import http from "http";
|
|
9596
|
-
import
|
|
9468
|
+
import fs14 from "fs";
|
|
9597
9469
|
function registerLoginCommand(program2) {
|
|
9598
9470
|
program2.command("login").description("registry \u306B\u30ED\u30B0\u30A4\u30F3\u3057\u3066 publish token \u3092\u53D6\u5F97").option("--registry <name>", "\u5BFE\u8C61 registry \u540D (\u30C7\u30D5\u30A9\u30EB\u30C8: official)").option("--local", "token \u3092\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30ED\u30FC\u30AB\u30EB\u306E config.local.yaml \u306B\u4FDD\u5B58").action(async (opts2) => {
|
|
9599
9471
|
const registryName = opts2.registry || "official";
|
|
@@ -9606,7 +9478,7 @@ function registerLoginCommand(program2) {
|
|
|
9606
9478
|
let targetConfigPath;
|
|
9607
9479
|
if (opts2.local) {
|
|
9608
9480
|
const mirDir = localPersonalConfigPath(process.cwd()).replace(/\/[^/]+$/, "");
|
|
9609
|
-
if (!
|
|
9481
|
+
if (!fs14.existsSync(mirDir)) {
|
|
9610
9482
|
error(".mir/ \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u5B58\u5728\u3057\u307E\u305B\u3093\u3002\u5148\u306B `mir init` \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
9611
9483
|
process.exit(1);
|
|
9612
9484
|
}
|
|
@@ -9711,16 +9583,16 @@ function registerLogoutCommand(program2) {
|
|
|
9711
9583
|
}
|
|
9712
9584
|
|
|
9713
9585
|
// src/commands/validate.ts
|
|
9714
|
-
import
|
|
9586
|
+
import fs15 from "fs";
|
|
9715
9587
|
function validateSnippet(name, cwd = process.cwd()) {
|
|
9716
9588
|
const errors = [];
|
|
9717
9589
|
const warnings = [];
|
|
9718
9590
|
validateSnippetName(name);
|
|
9719
9591
|
const yamlPath = snippetYamlPath(cwd, name);
|
|
9720
|
-
if (!
|
|
9592
|
+
if (!fs15.existsSync(yamlPath)) {
|
|
9721
9593
|
throw new SnippetNotFoundError(name);
|
|
9722
9594
|
}
|
|
9723
|
-
const yamlContent =
|
|
9595
|
+
const yamlContent = fs15.readFileSync(yamlPath, "utf-8");
|
|
9724
9596
|
let definition;
|
|
9725
9597
|
try {
|
|
9726
9598
|
definition = parseSnippetYaml(yamlContent);
|
|
@@ -9729,7 +9601,7 @@ function validateSnippet(name, cwd = process.cwd()) {
|
|
|
9729
9601
|
return { valid: false, errors, warnings };
|
|
9730
9602
|
}
|
|
9731
9603
|
const dirPath = snippetDirPath(cwd, name);
|
|
9732
|
-
if (!
|
|
9604
|
+
if (!fs15.existsSync(dirPath)) {
|
|
9733
9605
|
warnings.push(
|
|
9734
9606
|
t("validate.no-template-dir", { path: dirPath })
|
|
9735
9607
|
);
|
|
@@ -9799,7 +9671,7 @@ function getLocaleFromEnv() {
|
|
|
9799
9671
|
|
|
9800
9672
|
// src/cli.ts
|
|
9801
9673
|
var program = new Command();
|
|
9802
|
-
program.name("mir").description("\u30B9\u30CB\u30DA\u30C3\u30C8\u3092\u914D\u5E03\u30FB\u53D6\u5F97\u3059\u308B CLI \u30C4\u30FC\u30EB").version("0.0.2-
|
|
9674
|
+
program.name("mir").description("\u30B9\u30CB\u30DA\u30C3\u30C8\u3092\u914D\u5E03\u30FB\u53D6\u5F97\u3059\u308B CLI \u30C4\u30FC\u30EB").version("0.0.2-alpha08", "-v, --version").showHelpAfterError(true).option("--config <path>", "\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9 (\u30C7\u30D5\u30A9\u30EB\u30C8: ~/.mir/config.yaml)").option("--locale <lang>", "UI \u8A00\u8A9E (ja|en)").option("--no-interactive", "\u975E\u5BFE\u8A71\u30E2\u30FC\u30C9").configureHelp({
|
|
9803
9675
|
formatHelp(cmd, helper) {
|
|
9804
9676
|
const bold3 = "\x1B[1m";
|
|
9805
9677
|
const cyan3 = "\x1B[36m";
|
|
@@ -9869,7 +9741,6 @@ registerInstallCommand(program);
|
|
|
9869
9741
|
registerSyncCommand(program);
|
|
9870
9742
|
registerListCommand(program);
|
|
9871
9743
|
registerInfoCommand(program);
|
|
9872
|
-
registerSearchCommand(program);
|
|
9873
9744
|
registerCloneCommand(program);
|
|
9874
9745
|
registerPreviewCommand(program);
|
|
9875
9746
|
registerValidateCommand(program);
|