@anvil-works/anvil-cli 0.3.7 → 0.3.8

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.
Files changed (3) hide show
  1. package/dist/cli.js +60 -27
  2. package/dist/index.js +60 -27
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -44512,6 +44512,17 @@ var __webpack_exports__ = {};
44512
44512
  getRepoPath() {
44513
44513
  return this.repoPath;
44514
44514
  }
44515
+ async getGitDir() {
44516
+ try {
44517
+ const gitDir = (await this.git.revparse([
44518
+ "--git-dir"
44519
+ ])).trim();
44520
+ if (!external_path_default().isAbsolute(gitDir)) return external_path_default().resolve(this.repoPath, gitDir);
44521
+ return gitDir;
44522
+ } catch (e) {
44523
+ throw createGitError.commandFailed("rev-parse --git-dir", e.message);
44524
+ }
44525
+ }
44515
44526
  async getCurrentBranch() {
44516
44527
  try {
44517
44528
  const branchRef = await this.git.revparse([
@@ -46195,6 +46206,7 @@ var __webpack_exports__ = {};
46195
46206
  };
46196
46207
  class FileWatcher extends Emitter_Emitter {
46197
46208
  repoPath;
46209
+ gitDir;
46198
46210
  stagedOnly;
46199
46211
  getCurrentBranch;
46200
46212
  headWatcher = null;
@@ -46204,6 +46216,7 @@ var __webpack_exports__ = {};
46204
46216
  constructor(options){
46205
46217
  super();
46206
46218
  this.repoPath = external_path_default().resolve(options.repoPath);
46219
+ this.gitDir = options.gitDir;
46207
46220
  this.stagedOnly = options.stagedOnly ?? false;
46208
46221
  this.getCurrentBranch = options.getCurrentBranch;
46209
46222
  this.sessionId = Math.random().toString(36).substring(2, 10);
@@ -46216,7 +46229,7 @@ var __webpack_exports__ = {};
46216
46229
  else this.startFileWatcher();
46217
46230
  }
46218
46231
  startHeadWatcher() {
46219
- const headPath = external_path_default().join(this.repoPath, ".git", "HEAD");
46232
+ const headPath = external_path_default().join(this.gitDir, "HEAD");
46220
46233
  logger_logger.debug(`[FileWatcher ${this.sessionId}]`, `Setting up HEAD watcher: ${headPath}`);
46221
46234
  this.headWatcher = chokidar_esm.watch(headPath, {
46222
46235
  persistent: true,
@@ -46247,7 +46260,7 @@ var __webpack_exports__ = {};
46247
46260
  });
46248
46261
  }
46249
46262
  startIndexWatcher() {
46250
- const indexPath = external_path_default().join(this.repoPath, ".git", "index");
46263
+ const indexPath = external_path_default().join(this.gitDir, "index");
46251
46264
  logger_logger.verbose(`Setting up watcher for: ${indexPath}`);
46252
46265
  logger_logger.debug(`[FileWatcher ${this.sessionId}]`, `Setting up index watcher (staged-only mode): ${indexPath}`);
46253
46266
  if (!external_fs_.existsSync(indexPath)) return void logger_logger.error(`ERROR: Git index file not found at ${indexPath}`);
@@ -46952,6 +46965,10 @@ var __webpack_exports__ = {};
46952
46965
  metadata: optional(any())
46953
46966
  });
46954
46967
  function validateAnvilYaml(yamlContent) {
46968
+ if (yamlContent.includes("<<<<<<<") || yamlContent.includes(">>>>>>>")) {
46969
+ logger_logger.error("anvil.yaml contains git merge conflict markers. Please resolve conflicts manually.");
46970
+ return false;
46971
+ }
46955
46972
  try {
46956
46973
  const data = js_yaml_load(yamlContent);
46957
46974
  const result = safeParse(AnvilYamlSchema, data);
@@ -48315,47 +48332,61 @@ var __webpack_exports__ = {};
48315
48332
  }
48316
48333
  class SyncManager extends Emitter_Emitter {
48317
48334
  config;
48335
+ syncInProgress = false;
48318
48336
  constructor(config){
48319
48337
  super();
48320
48338
  this.config = config;
48321
48339
  }
48322
48340
  async syncRemoteChanges(knownLocalChanges) {
48323
- const oldCommitId = this.config.getCommitId();
48324
- let locallyChangedFiles;
48325
- if (knownLocalChanges) locallyChangedFiles = knownLocalChanges;
48326
- else {
48327
- const status = await this.config.gitService.getStatus();
48328
- locallyChangedFiles = buildLocalChangesSet(status);
48329
- }
48330
- await this.fetchAndResetFromAnvil();
48331
- const newCommitId = await this.config.gitService.getCommitId();
48332
- this.config.setCommitId(newCommitId);
48333
- const remoteChangedFiles = await detectRemoteChanges(this.config.gitService, oldCommitId, newCommitId);
48334
- const statusAfter = await this.config.gitService.getStatus();
48335
- const newChanges = extractChangesFromStatus(statusAfter);
48336
- if (0 === newChanges.length) {
48337
- logger_logger.verbose(chalk_source.gray(" No local changes - working directory is clean"));
48341
+ if (this.syncInProgress) {
48342
+ logger_logger.debug("Sync already in progress, skipping");
48338
48343
  return {
48339
48344
  localOnlyChanges: [],
48340
48345
  conflicts: []
48341
48346
  };
48342
48347
  }
48343
- const result = categorizeChanges(newChanges, locallyChangedFiles, remoteChangedFiles);
48344
- await acceptRemoteChanges(this.config.gitService, result.remoteOnlyChanges);
48345
- logConflictResolution(result);
48346
- return {
48347
- localOnlyChanges: result.localOnlyChanges,
48348
- conflicts: result.conflicts
48349
- };
48348
+ this.syncInProgress = true;
48349
+ try {
48350
+ const oldCommitId = this.config.getCommitId();
48351
+ let locallyChangedFiles;
48352
+ if (knownLocalChanges) locallyChangedFiles = knownLocalChanges;
48353
+ else {
48354
+ const status = await this.config.gitService.getStatus();
48355
+ locallyChangedFiles = buildLocalChangesSet(status);
48356
+ }
48357
+ await this.fetchAndResetFromAnvil();
48358
+ const newCommitId = await this.config.gitService.getCommitId();
48359
+ this.config.setCommitId(newCommitId);
48360
+ const remoteChangedFiles = await detectRemoteChanges(this.config.gitService, oldCommitId, newCommitId);
48361
+ const statusAfter = await this.config.gitService.getStatus();
48362
+ const newChanges = extractChangesFromStatus(statusAfter);
48363
+ if (0 === newChanges.length) {
48364
+ logger_logger.verbose(chalk_source.gray(" No local changes - working directory is clean"));
48365
+ return {
48366
+ localOnlyChanges: [],
48367
+ conflicts: []
48368
+ };
48369
+ }
48370
+ const result = categorizeChanges(newChanges, locallyChangedFiles, remoteChangedFiles);
48371
+ await acceptRemoteChanges(this.config.gitService, result.remoteOnlyChanges);
48372
+ logConflictResolution(result);
48373
+ return {
48374
+ localOnlyChanges: result.localOnlyChanges,
48375
+ conflicts: result.conflicts
48376
+ };
48377
+ } finally{
48378
+ this.syncInProgress = false;
48379
+ }
48350
48380
  }
48351
48381
  async fetchAndResetFromAnvil() {
48352
48382
  const validToken = await auth_getValidAuthToken(this.config.anvilUrl, this.config.username);
48353
48383
  this.config.setAuthToken(validToken);
48354
48384
  const httpUrl = getGitFetchUrl(this.config.appId, this.config.getAuthToken(), this.config.anvilUrl);
48355
48385
  const currentBranch = this.config.getCurrentBranch();
48356
- await this.config.gitService.fetch(httpUrl, `+${currentBranch}:anvil-sync-temp`);
48357
- await this.config.gitService.reset("anvil-sync-temp", "mixed");
48358
- await this.config.gitService.deleteRef("refs/heads/anvil-sync-temp");
48386
+ const tempRef = `anvil-sync-temp-${Date.now()}`;
48387
+ await this.config.gitService.fetch(httpUrl, `+${currentBranch}:${tempRef}`);
48388
+ await this.config.gitService.reset(tempRef, "mixed");
48389
+ await this.config.gitService.deleteRef(`refs/heads/${tempRef}`);
48359
48390
  await this.config.gitService.checkout([
48360
48391
  ".anvil_editor.yaml",
48361
48392
  "anvil.yaml"
@@ -48615,8 +48646,10 @@ var __webpack_exports__ = {};
48615
48646
  }
48616
48647
  async startWatching() {
48617
48648
  logger_logger.debug(`[Session ${this.sessionId}]`, "Starting watchers...");
48649
+ const gitDir = await this.gitService.getGitDir();
48618
48650
  this.fileWatcher = new FileWatcher({
48619
48651
  repoPath: this.repoPath,
48652
+ gitDir,
48620
48653
  stagedOnly: this.stagedOnly,
48621
48654
  getCurrentBranch: async ()=>this.gitService.getCurrentBranch()
48622
48655
  });
package/dist/index.js CHANGED
@@ -19658,6 +19658,17 @@ var __webpack_exports__ = {};
19658
19658
  getRepoPath() {
19659
19659
  return this.repoPath;
19660
19660
  }
19661
+ async getGitDir() {
19662
+ try {
19663
+ const gitDir = (await this.git.revparse([
19664
+ "--git-dir"
19665
+ ])).trim();
19666
+ if (!external_path_default().isAbsolute(gitDir)) return external_path_default().resolve(this.repoPath, gitDir);
19667
+ return gitDir;
19668
+ } catch (e) {
19669
+ throw createGitError.commandFailed("rev-parse --git-dir", e.message);
19670
+ }
19671
+ }
19661
19672
  async getCurrentBranch() {
19662
19673
  try {
19663
19674
  const branchRef = await this.git.revparse([
@@ -21341,6 +21352,7 @@ var __webpack_exports__ = {};
21341
21352
  };
21342
21353
  class FileWatcher extends Emitter {
21343
21354
  repoPath;
21355
+ gitDir;
21344
21356
  stagedOnly;
21345
21357
  getCurrentBranch;
21346
21358
  headWatcher = null;
@@ -21350,6 +21362,7 @@ var __webpack_exports__ = {};
21350
21362
  constructor(options){
21351
21363
  super();
21352
21364
  this.repoPath = external_path_default().resolve(options.repoPath);
21365
+ this.gitDir = options.gitDir;
21353
21366
  this.stagedOnly = options.stagedOnly ?? false;
21354
21367
  this.getCurrentBranch = options.getCurrentBranch;
21355
21368
  this.sessionId = Math.random().toString(36).substring(2, 10);
@@ -21362,7 +21375,7 @@ var __webpack_exports__ = {};
21362
21375
  else this.startFileWatcher();
21363
21376
  }
21364
21377
  startHeadWatcher() {
21365
- const headPath = external_path_default().join(this.repoPath, ".git", "HEAD");
21378
+ const headPath = external_path_default().join(this.gitDir, "HEAD");
21366
21379
  logger_logger.debug(`[FileWatcher ${this.sessionId}]`, `Setting up HEAD watcher: ${headPath}`);
21367
21380
  this.headWatcher = chokidar_esm.watch(headPath, {
21368
21381
  persistent: true,
@@ -21393,7 +21406,7 @@ var __webpack_exports__ = {};
21393
21406
  });
21394
21407
  }
21395
21408
  startIndexWatcher() {
21396
- const indexPath = external_path_default().join(this.repoPath, ".git", "index");
21409
+ const indexPath = external_path_default().join(this.gitDir, "index");
21397
21410
  logger_logger.verbose(`Setting up watcher for: ${indexPath}`);
21398
21411
  logger_logger.debug(`[FileWatcher ${this.sessionId}]`, `Setting up index watcher (staged-only mode): ${indexPath}`);
21399
21412
  if (!external_fs_.existsSync(indexPath)) return void logger_logger.error(`ERROR: Git index file not found at ${indexPath}`);
@@ -22550,6 +22563,10 @@ var __webpack_exports__ = {};
22550
22563
  metadata: optional(any())
22551
22564
  });
22552
22565
  function validateAnvilYaml(yamlContent) {
22566
+ if (yamlContent.includes("<<<<<<<") || yamlContent.includes(">>>>>>>")) {
22567
+ logger_logger.error("anvil.yaml contains git merge conflict markers. Please resolve conflicts manually.");
22568
+ return false;
22569
+ }
22553
22570
  try {
22554
22571
  const data = load(yamlContent);
22555
22572
  const result = safeParse(AnvilYamlSchema, data);
@@ -23913,47 +23930,61 @@ var __webpack_exports__ = {};
23913
23930
  }
23914
23931
  class SyncManager extends Emitter {
23915
23932
  config;
23933
+ syncInProgress = false;
23916
23934
  constructor(config){
23917
23935
  super();
23918
23936
  this.config = config;
23919
23937
  }
23920
23938
  async syncRemoteChanges(knownLocalChanges) {
23921
- const oldCommitId = this.config.getCommitId();
23922
- let locallyChangedFiles;
23923
- if (knownLocalChanges) locallyChangedFiles = knownLocalChanges;
23924
- else {
23925
- const status = await this.config.gitService.getStatus();
23926
- locallyChangedFiles = buildLocalChangesSet(status);
23927
- }
23928
- await this.fetchAndResetFromAnvil();
23929
- const newCommitId = await this.config.gitService.getCommitId();
23930
- this.config.setCommitId(newCommitId);
23931
- const remoteChangedFiles = await detectRemoteChanges(this.config.gitService, oldCommitId, newCommitId);
23932
- const statusAfter = await this.config.gitService.getStatus();
23933
- const newChanges = extractChangesFromStatus(statusAfter);
23934
- if (0 === newChanges.length) {
23935
- logger_logger.verbose(chalk_source.gray(" No local changes - working directory is clean"));
23939
+ if (this.syncInProgress) {
23940
+ logger_logger.debug("Sync already in progress, skipping");
23936
23941
  return {
23937
23942
  localOnlyChanges: [],
23938
23943
  conflicts: []
23939
23944
  };
23940
23945
  }
23941
- const result = categorizeChanges(newChanges, locallyChangedFiles, remoteChangedFiles);
23942
- await acceptRemoteChanges(this.config.gitService, result.remoteOnlyChanges);
23943
- logConflictResolution(result);
23944
- return {
23945
- localOnlyChanges: result.localOnlyChanges,
23946
- conflicts: result.conflicts
23947
- };
23946
+ this.syncInProgress = true;
23947
+ try {
23948
+ const oldCommitId = this.config.getCommitId();
23949
+ let locallyChangedFiles;
23950
+ if (knownLocalChanges) locallyChangedFiles = knownLocalChanges;
23951
+ else {
23952
+ const status = await this.config.gitService.getStatus();
23953
+ locallyChangedFiles = buildLocalChangesSet(status);
23954
+ }
23955
+ await this.fetchAndResetFromAnvil();
23956
+ const newCommitId = await this.config.gitService.getCommitId();
23957
+ this.config.setCommitId(newCommitId);
23958
+ const remoteChangedFiles = await detectRemoteChanges(this.config.gitService, oldCommitId, newCommitId);
23959
+ const statusAfter = await this.config.gitService.getStatus();
23960
+ const newChanges = extractChangesFromStatus(statusAfter);
23961
+ if (0 === newChanges.length) {
23962
+ logger_logger.verbose(chalk_source.gray(" No local changes - working directory is clean"));
23963
+ return {
23964
+ localOnlyChanges: [],
23965
+ conflicts: []
23966
+ };
23967
+ }
23968
+ const result = categorizeChanges(newChanges, locallyChangedFiles, remoteChangedFiles);
23969
+ await acceptRemoteChanges(this.config.gitService, result.remoteOnlyChanges);
23970
+ logConflictResolution(result);
23971
+ return {
23972
+ localOnlyChanges: result.localOnlyChanges,
23973
+ conflicts: result.conflicts
23974
+ };
23975
+ } finally{
23976
+ this.syncInProgress = false;
23977
+ }
23948
23978
  }
23949
23979
  async fetchAndResetFromAnvil() {
23950
23980
  const validToken = await auth_getValidAuthToken(this.config.anvilUrl, this.config.username);
23951
23981
  this.config.setAuthToken(validToken);
23952
23982
  const httpUrl = getGitFetchUrl(this.config.appId, this.config.getAuthToken(), this.config.anvilUrl);
23953
23983
  const currentBranch = this.config.getCurrentBranch();
23954
- await this.config.gitService.fetch(httpUrl, `+${currentBranch}:anvil-sync-temp`);
23955
- await this.config.gitService.reset("anvil-sync-temp", "mixed");
23956
- await this.config.gitService.deleteRef("refs/heads/anvil-sync-temp");
23984
+ const tempRef = `anvil-sync-temp-${Date.now()}`;
23985
+ await this.config.gitService.fetch(httpUrl, `+${currentBranch}:${tempRef}`);
23986
+ await this.config.gitService.reset(tempRef, "mixed");
23987
+ await this.config.gitService.deleteRef(`refs/heads/${tempRef}`);
23957
23988
  await this.config.gitService.checkout([
23958
23989
  ".anvil_editor.yaml",
23959
23990
  "anvil.yaml"
@@ -24213,8 +24244,10 @@ var __webpack_exports__ = {};
24213
24244
  }
24214
24245
  async startWatching() {
24215
24246
  logger_logger.debug(`[Session ${this.sessionId}]`, "Starting watchers...");
24247
+ const gitDir = await this.gitService.getGitDir();
24216
24248
  this.fileWatcher = new FileWatcher({
24217
24249
  repoPath: this.repoPath,
24250
+ gitDir,
24218
24251
  stagedOnly: this.stagedOnly,
24219
24252
  getCurrentBranch: async ()=>this.gitService.getCurrentBranch()
24220
24253
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvil-works/anvil-cli",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "CLI tool for developing Anvil apps locally",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",