ziku 0.22.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +35 -9
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import * as p from "@clack/prompts";
|
|
4
4
|
import { defineCommand, runMain } from "citty";
|
|
5
|
-
import { copyFileSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { accessSync, constants, copyFileSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
7
|
import { dirname, join, resolve } from "pathe";
|
|
8
8
|
import * as YAML from "yaml";
|
|
@@ -14,6 +14,7 @@ import { applyPatch, createPatch, diffWords, structuredPatch } from "diff";
|
|
|
14
14
|
import pc, { default as pc$1 } from "picocolors";
|
|
15
15
|
import ignore from "ignore";
|
|
16
16
|
import { glob, globSync } from "tinyglobby";
|
|
17
|
+
import { homedir, tmpdir } from "node:os";
|
|
17
18
|
import { match } from "ts-pattern";
|
|
18
19
|
import { execFileSync } from "node:child_process";
|
|
19
20
|
import { Octokit } from "@octokit/rest";
|
|
@@ -26,7 +27,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
26
27
|
|
|
27
28
|
//#endregion
|
|
28
29
|
//#region package.json
|
|
29
|
-
var version$2 = "0.22.
|
|
30
|
+
var version$2 = "0.22.1";
|
|
30
31
|
|
|
31
32
|
//#endregion
|
|
32
33
|
//#region src/modules/schemas.ts
|
|
@@ -872,7 +873,7 @@ function getEffectivePatterns(_moduleId, modulePatterns, config) {
|
|
|
872
873
|
*
|
|
873
874
|
* 削除条件: ziku が別の UI フレームワーク(ink 等)に移行する場合。
|
|
874
875
|
*/
|
|
875
|
-
const version$1 = "0.22.
|
|
876
|
+
const version$1 = "0.22.1";
|
|
876
877
|
/** CLI の開始表示 */
|
|
877
878
|
function intro(command) {
|
|
878
879
|
const title = command ? `ziku ${command}` : "ziku";
|
|
@@ -1170,6 +1171,28 @@ function applyWordDiffAndColorize(lines) {
|
|
|
1170
1171
|
//#region src/utils/template.ts
|
|
1171
1172
|
const TEMPLATE_SOURCE = "gh:tktcorporation/.github";
|
|
1172
1173
|
/**
|
|
1174
|
+
* giget のキャッシュディレクトリが書き込み可能か確認し、不可能なら XDG_CACHE_HOME を
|
|
1175
|
+
* 書き込み可能な一時ディレクトリにフォールバックさせる。
|
|
1176
|
+
*
|
|
1177
|
+
* 背景: giget は内部で homedir()/.cache/giget にキャッシュを作成するが、
|
|
1178
|
+
* Codespaces 等の環境で homedir のキャッシュディレクトリに書き込み権限がない場合に
|
|
1179
|
+
* EACCES エラーが発生する。XDG_CACHE_HOME が設定済みなら giget はそちらを使うため、
|
|
1180
|
+
* フォールバック先として tmpdir を設定する。
|
|
1181
|
+
*
|
|
1182
|
+
* 呼び出し元: downloadTemplateToTemp(), fetchTemplates()
|
|
1183
|
+
* giget が XDG_CACHE_HOME 対応をやめれば不要になる。
|
|
1184
|
+
*/
|
|
1185
|
+
function ensureGigetCacheDir() {
|
|
1186
|
+
if (process.env.XDG_CACHE_HOME) return;
|
|
1187
|
+
const defaultCacheDir = resolve(homedir(), ".cache");
|
|
1188
|
+
try {
|
|
1189
|
+
if (!existsSync(defaultCacheDir)) mkdirSync(defaultCacheDir, { recursive: true });
|
|
1190
|
+
accessSync(defaultCacheDir, constants.W_OK);
|
|
1191
|
+
} catch {
|
|
1192
|
+
process.env.XDG_CACHE_HOME = resolve(tmpdir(), "giget-cache");
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1173
1196
|
* DevEnvConfig の source フィールドから giget 用のテンプレートソース文字列を構築する。
|
|
1174
1197
|
*
|
|
1175
1198
|
* 背景: giget は "gh:owner/repo" または "gh:owner/repo#ref" 形式を期待する。
|
|
@@ -1188,6 +1211,7 @@ function buildTemplateSource(source) {
|
|
|
1188
1211
|
*/
|
|
1189
1212
|
async function downloadTemplateToTemp(targetDir, source) {
|
|
1190
1213
|
const tempDir = join(targetDir, ".devenv-temp");
|
|
1214
|
+
ensureGigetCacheDir();
|
|
1191
1215
|
const { dir: templateDir } = await downloadTemplate(source ?? TEMPLATE_SOURCE, {
|
|
1192
1216
|
dir: tempDir,
|
|
1193
1217
|
force: true
|
|
@@ -1254,11 +1278,13 @@ async function fetchTemplates(options) {
|
|
|
1254
1278
|
const tempDir = join(targetDir, ".devenv-temp");
|
|
1255
1279
|
let templateDir;
|
|
1256
1280
|
try {
|
|
1257
|
-
if (shouldDownload)
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1281
|
+
if (shouldDownload) {
|
|
1282
|
+
ensureGigetCacheDir();
|
|
1283
|
+
templateDir = (await downloadTemplate(TEMPLATE_SOURCE, {
|
|
1284
|
+
dir: tempDir,
|
|
1285
|
+
force: true
|
|
1286
|
+
})).dir;
|
|
1287
|
+
} else templateDir = preDownloadedDir;
|
|
1262
1288
|
const gitignore = await loadMergedGitignore([targetDir, templateDir]);
|
|
1263
1289
|
for (const moduleId of modules) {
|
|
1264
1290
|
const moduleDef = moduleList ? moduleList.find((m) => m.id === moduleId) : getModuleById(moduleId);
|
|
@@ -2040,7 +2066,7 @@ async function hashFiles(dir, patterns) {
|
|
|
2040
2066
|
|
|
2041
2067
|
//#endregion
|
|
2042
2068
|
//#region src/commands/init.ts
|
|
2043
|
-
const version = "0.22.
|
|
2069
|
+
const version = "0.22.1";
|
|
2044
2070
|
const initCommand = defineCommand({
|
|
2045
2071
|
meta: {
|
|
2046
2072
|
name: "ziku",
|