create-dwy 0.13.6 → 0.13.7
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/utils.js +20 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# create-dwy
|
|
2
2
|
|
|
3
|
+
## 0.13.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `dwy` 同步模板前会先检查本地缓存仓库 `origin` 是否仍指向当前 CLI 目标仓库 `https://github.com/danweiyuancircle/dwy-ai-experience.git`;若不一致,则删除 `/Users/chances/.dwy/cache/dwy` 后重新 clone,避免旧 Gitee 缓存继续被 pull。
|
|
8
|
+
|
|
3
9
|
## 0.13.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
package/src/utils.js
CHANGED
|
@@ -9,16 +9,33 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
9
9
|
|
|
10
10
|
export const PACKAGE_ROOT = path.resolve(__dirname, '..')
|
|
11
11
|
export const CACHE_DIR = path.join(process.env.HOME, '.dwy', 'cache')
|
|
12
|
-
export const DWY_REPO_URL = 'https://github.com/danweiyuancircle/dwy-
|
|
12
|
+
export const DWY_REPO_URL = 'https://github.com/danweiyuancircle/dwy-ai-experience.git'
|
|
13
|
+
|
|
14
|
+
export async function needsRepoReclone(git, repoUrl) {
|
|
15
|
+
const remotes = await git.getRemotes(true)
|
|
16
|
+
const origin = remotes.find(remote => remote.name === 'origin')
|
|
17
|
+
if (!origin) return true
|
|
18
|
+
|
|
19
|
+
const fetchUrl = origin.refs?.fetch
|
|
20
|
+
const pushUrl = origin.refs?.push
|
|
21
|
+
return fetchUrl !== repoUrl || pushUrl !== repoUrl
|
|
22
|
+
}
|
|
13
23
|
|
|
14
24
|
export async function ensureRepoCache() {
|
|
15
25
|
await fs.ensureDir(CACHE_DIR)
|
|
16
26
|
const repoDir = path.join(CACHE_DIR, 'dwy')
|
|
17
27
|
|
|
18
28
|
if (await fs.pathExists(path.join(repoDir, '.git'))) {
|
|
19
|
-
console.log(chalk.gray('Pulling latest templates...'))
|
|
20
29
|
const git = simpleGit(repoDir)
|
|
21
|
-
await git
|
|
30
|
+
if (await needsRepoReclone(git, DWY_REPO_URL)) {
|
|
31
|
+
console.log(chalk.gray('Cached templates point to another repo, recreating cache...'))
|
|
32
|
+
await fs.remove(repoDir)
|
|
33
|
+
console.log(chalk.gray('Cloning template repo...'))
|
|
34
|
+
await simpleGit().clone(DWY_REPO_URL, repoDir)
|
|
35
|
+
} else {
|
|
36
|
+
console.log(chalk.gray('Pulling latest templates...'))
|
|
37
|
+
await git.pull()
|
|
38
|
+
}
|
|
22
39
|
} else {
|
|
23
40
|
console.log(chalk.gray('Cloning template repo...'))
|
|
24
41
|
await simpleGit().clone(DWY_REPO_URL, repoDir)
|