@repokit/core 3.0.4 → 3.0.6

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/Cargo.lock CHANGED
@@ -900,7 +900,7 @@ checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c"
900
900
 
901
901
  [[package]]
902
902
  name = "repokit"
903
- version = "3.0.4"
903
+ version = "3.0.6"
904
904
  dependencies = [
905
905
  "alphanumeric-sort",
906
906
  "colored",
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "repokit"
3
- version = "3.0.4"
3
+ version = "3.0.6"
4
4
  edition = "2024"
5
5
 
6
6
  [[bin]]
@@ -1,4 +1,4 @@
1
- CURRENT_VERSION="3.0.4"
1
+ CURRENT_VERSION="3.0.6"
2
2
  CWD=$(pwd)
3
3
 
4
4
  REPLACEMENT="/node_modules"
@@ -31,36 +31,37 @@ ROOT_COMMIT=$(git rev-list --parents HEAD | tail -1) || ROOT_COMMIT=""
31
31
 
32
32
  cd
33
33
 
34
- CACHE_FILE_OR_DIRECTORY=".repokit";
35
- NEW_VERSION_FILE=".repokit_version"
36
- NEW_SETTINGS_FILE=".repokit_settings"
37
- REPO_CACHE_DIRECTORY="$CACHE_FILE_OR_DIRECTORY/$ROOT_COMMIT";
38
-
39
- CACHED_THEME=""
34
+ CACHE_FILE=".repokit";
35
+ CACHE_DIRECTORY=".repokit_cache";
36
+ NEW_SETTINGS_FILE=".settings"
37
+ REPO_CACHE_DIRECTORY="$CACHE_DIRECTORY/$ROOT_COMMIT"
38
+ LAST_THEME_USED=""
39
+ BACK_PORTING=0
40
+
41
+ if [ -n "$ROOT_COMMIT" ] && [ -f "$REPO_CACHE_DIRECTORY/$NEW_SETTINGS_FILE" ]; then
42
+ BACK_PORTING=1
43
+ cd "$REPO_CACHE_DIRECTORY"
44
+ read -r LAST_THEME_USED < "$NEW_SETTINGS_FILE"
45
+ rm "$NEW_SETTINGS_FILE"
46
+ cd
47
+ fi
40
48
 
41
- if [ -d "$CACHE_FILE_OR_DIRECTORY" ]; then
42
- if [ -n "$ROOT_COMMIT" ] && [ -d "$REPO_CACHE_DIRECTORY" ]; then
43
- {
44
- read -r CACHED_THEME
45
- } < "$REPO_CACHE_DIRECTORY/$NEW_SETTINGS_FILE"
46
- fi
47
- rm -rf "$CACHE_FILE_OR_DIRECTORY"
48
- elif [ -f "$CACHE_FILE_OR_DIRECTORY" ]; then
49
- read -r PREVIOUS_VERSION < "$CACHE_FILE_OR_DIRECTORY"
50
- if [ "$PREVIOUS_VERSION" == "$CURRENT_VERSION" ]; then
51
- exit 0;
49
+ if [ ! -f "$CACHE_FILE" ]; then
50
+ touch "$CACHE_FILE"
51
+ elif [ "$BACK_PORTING" == 0 ]; then
52
+ read -r LAST_VERSION_USED < "$CACHE_FILE"
53
+ if [ "$LAST_VERSION_USED" == "$CURRENT_VERSION" ]; then
54
+ exit 0
52
55
  fi
53
56
  fi
54
57
 
55
- touch "$CACHE_FILE_OR_DIRECTORY"
56
-
57
- if [ -n "$CACHED_THEME" ]; then
58
- printf "$CURRENT_VERSION\n$CACHED_THEME\n" > "$CACHE_FILE_OR_DIRECTORY"
59
- else
58
+ if [ -n "$LAST_THEME_USED" ]; then
59
+ echo "$CURRENT_VERSION\n$LAST_THEME_USED\n" > "$CACHE_FILE"
60
+ else
60
61
  TEMP_FILE=".repokit_tmp";
61
62
  printf "$CURRENT_VERSION\n" > "$TEMP_FILE"
62
- tail +2 "$CACHE_FILE_OR_DIRECTORY" >> "$TEMP_FILE"
63
- mv "$TEMP_FILE" "$CACHE_FILE_OR_DIRECTORY"
63
+ tail +2 "$CACHE_FILE" >> "$TEMP_FILE"
64
+ mv "$TEMP_FILE" "$CACHE_FILE"
64
65
  fi
65
66
 
66
67
 
@@ -93,6 +93,18 @@ impl InternalFileSystem {
93
93
  });
94
94
  }
95
95
 
96
+ pub fn store_current_version(&self, version: &str) {
97
+ self.read_dot_file(&mut |lines, path| {
98
+ let mut content: Vec<String> = lines.map(|line| line.unwrap()).collect();
99
+ if !content.is_empty() {
100
+ content[0] = version.to_owned();
101
+ } else {
102
+ content.push(version.to_owned());
103
+ }
104
+ fs::write(path, content.join("\n"))
105
+ });
106
+ }
107
+
96
108
  pub fn read_dot_file<R>(
97
109
  &self,
98
110
  func: &mut impl FnMut(Lines<BufReader<File>>, PathBuf) -> R,
@@ -26,6 +26,7 @@ impl RuntimeCompiler {
26
26
  if let Some(errors) = RuntimeCompiler::run_post_install(&package_path) {
27
27
  println!("{errors}");
28
28
  } else {
29
+ InternalFileSystem::new(root).store_current_version(installed_version);
29
30
  RuntimeCompiler::re_run_command();
30
31
  }
31
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repokit/core",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "A knowledgebase for your repository - wrapped in a CLI",
5
5
  "keywords": [
6
6
  "cli",