@fugood/bricks-project 2.24.0-beta.10 → 2.24.0-beta.12
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/package.json +3 -3
- package/tools/pull.ts +23 -8
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-project",
|
|
3
|
-
"version": "2.24.0-beta.
|
|
3
|
+
"version": "2.24.0-beta.12",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"typecheck": "tsc --noEmit",
|
|
7
7
|
"build": "bun scripts/build.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@fugood/bricks-cli": "^2.24.0-beta.
|
|
10
|
+
"@fugood/bricks-cli": "^2.24.0-beta.12",
|
|
11
11
|
"@huggingface/gguf": "^0.3.2",
|
|
12
12
|
"@iarna/toml": "^3.0.0",
|
|
13
13
|
"@modelcontextprotocol/sdk": "^1.15.0",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"lodash": "^4.17.4",
|
|
22
22
|
"uuid": "^8.3.1"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "7c1dbd88ecddb12dba27ddb78147d208488f9c81"
|
|
25
25
|
}
|
package/tools/pull.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { $ } from 'bun'
|
|
|
2
2
|
import { format } from 'prettier'
|
|
3
3
|
|
|
4
4
|
const cwd = process.cwd()
|
|
5
|
+
const args = process.argv.slice(2)
|
|
6
|
+
const force = args.includes('--force') || args.includes('-f')
|
|
5
7
|
|
|
6
8
|
// Check git status
|
|
7
9
|
const { exitCode } = await $`cd ${cwd} && git status`.nothrow()
|
|
@@ -9,8 +11,15 @@ const isGitRepo = exitCode === 0
|
|
|
9
11
|
|
|
10
12
|
if (isGitRepo) {
|
|
11
13
|
const unstagedChanges = await $`cd ${cwd} && git diff --name-only --diff-filter=ACMR`.text()
|
|
12
|
-
if (unstagedChanges)
|
|
13
|
-
|
|
14
|
+
if (unstagedChanges) {
|
|
15
|
+
if (force) {
|
|
16
|
+
console.log('Force mode: committing unstaged changes before pull...')
|
|
17
|
+
await $`cd ${cwd} && git add .`
|
|
18
|
+
await $`cd ${cwd} && git commit -m ${'chore(force-pull): saved unstaged changes before pull'}`
|
|
19
|
+
} else {
|
|
20
|
+
throw new Error('Unstaged changes found, please commit or stash your changes before pulling')
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
} else {
|
|
15
24
|
const confirmContinue = prompt(
|
|
16
25
|
'No git repository found, so it will not be safe to pull, continue? (y/n)',
|
|
@@ -25,6 +34,7 @@ const isModule = app.type === 'module'
|
|
|
25
34
|
const command = isModule ? 'module' : 'app'
|
|
26
35
|
|
|
27
36
|
// Fetch project files using CLI
|
|
37
|
+
console.log(`Pulling ${command} project (${app.id})...`)
|
|
28
38
|
const result = await $`bricks ${command} project-pull ${app.id} --json`.quiet().nothrow()
|
|
29
39
|
|
|
30
40
|
if (result.exitCode !== 0) {
|
|
@@ -40,7 +50,8 @@ if (result.exitCode !== 0) {
|
|
|
40
50
|
const { files, lastCommitId } = JSON.parse(result.stdout.toString())
|
|
41
51
|
|
|
42
52
|
let useMain = false
|
|
43
|
-
if (isGitRepo) {
|
|
53
|
+
if (isGitRepo && !force) {
|
|
54
|
+
console.log(`Checking commit ${lastCommitId}...`)
|
|
44
55
|
const found = (await $`cd ${cwd} && git rev-list -1 ${lastCommitId}`.nothrow().text())
|
|
45
56
|
.trim()
|
|
46
57
|
.match(/^[\da-f]{40}$/)
|
|
@@ -86,13 +97,17 @@ await Promise.all(
|
|
|
86
97
|
|
|
87
98
|
if (isGitRepo) {
|
|
88
99
|
await $`cd ${cwd} && git add .`
|
|
89
|
-
const commitMsg =
|
|
90
|
-
?
|
|
91
|
-
:
|
|
100
|
+
const commitMsg = force
|
|
101
|
+
? `chore(force-pull): apply force pull-${command}`
|
|
102
|
+
: isModule
|
|
103
|
+
? 'chore(project): apply file changes from BRICKS module'
|
|
104
|
+
: 'chore(project): apply file changes from BRICKS application'
|
|
92
105
|
await $`cd ${cwd} && git commit -m ${commitMsg}`
|
|
93
|
-
if (!useMain) {
|
|
106
|
+
if (!force && !useMain) {
|
|
94
107
|
await $`cd ${cwd} && git merge main`
|
|
95
108
|
}
|
|
96
109
|
}
|
|
97
110
|
|
|
98
|
-
console.log(
|
|
111
|
+
console.log(
|
|
112
|
+
`${isModule ? 'Module' : 'App'} project pulled: ${files.length} files${force ? ' (force)' : ''}`,
|
|
113
|
+
)
|