@repokit/core 1.3.0 → 1.3.2

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.
@@ -1,5 +1,5 @@
1
1
  import type { ICommand, IRepoKitConfig } from "./types";
2
- import type { RepoKitCommand } from "./RepoKitCommand";
2
+ import { RepoKitCommand } from "./RepoKitCommand";
3
3
 
4
4
  export class RepoKitConfig implements Required<IRepoKitConfig> {
5
5
  project: string;
@@ -8,6 +8,6 @@ export class RepoKitConfig implements Required<IRepoKitConfig> {
8
8
  constructor({ project, commands = {}, thirdParty = [] }: IRepoKitConfig) {
9
9
  this.project = project;
10
10
  this.commands = commands;
11
- this.thirdParty = thirdParty;
11
+ this.thirdParty = thirdParty.map(command => new RepoKitCommand(command));
12
12
  }
13
13
  }
@@ -1,7 +1,9 @@
1
1
  set -e
2
2
 
3
3
  SCRIPT_ORIGIN=$(pwd)
4
- REPO_ROOT=$(git rev-parse --show-toplevel)
4
+ GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
5
+ NODE_MODULES_PARENT="$(pwd)/../"
6
+ REPO_ROOT=${GIT_ROOT:-$NODE_MODULES_PARENT}
5
7
 
6
8
  cd $REPO_ROOT
7
9
 
@@ -35,7 +37,7 @@ fi
35
37
 
36
38
  echo "Installing Repokit CLI"
37
39
 
38
- cd "$SCRIPT_ORIGIN"
40
+ cd $SCRIPT_ORIGIN
39
41
 
40
42
  echo "Compiling from $SCRIPT_ORIGIN"
41
43
 
@@ -1,6 +1,8 @@
1
1
  use normalize_path::NormalizePath;
2
2
  use std::path::{Path, PathBuf};
3
3
 
4
+ use crate::{executor::executor::Executor, logger::logger::Logger};
5
+
4
6
  pub struct InternalFileSystem {
5
7
  root: String,
6
8
  }
@@ -25,6 +27,23 @@ impl InternalFileSystem {
25
27
  self.path_buf_to_str(self.templates_directory().join(file_name))
26
28
  }
27
29
 
30
+ pub fn find_root() -> String {
31
+ let root = Executor::exec("echo $(git rev-parse --show-toplevel 2>/dev/null)", |cmd| {
32
+ cmd
33
+ });
34
+ if root.is_empty() {
35
+ Logger::exit_with_info(
36
+ format!(
37
+ "To start using {}, please initialize your git repository by running {}",
38
+ Logger::blue("Repokit"),
39
+ Logger::green_bright("git init")
40
+ )
41
+ .as_str(),
42
+ );
43
+ }
44
+ root
45
+ }
46
+
28
47
  fn commands_directory(&self) -> PathBuf {
29
48
  self.absolute(format!("{}/commands", self.package_directory()).as_str())
30
49
  }
package/internals/main.rs CHANGED
@@ -1,6 +1,6 @@
1
1
  use crate::{
2
- executor::executor::Executor, internal_commands::typescript_command::TypescriptCommand,
3
- repokit::repokit::RepoKit,
2
+ internal_commands::typescript_command::TypescriptCommand,
3
+ internal_filesystem::internal_filesystem::InternalFileSystem, repokit::repokit::RepoKit,
4
4
  };
5
5
 
6
6
  mod configuration;
@@ -14,7 +14,7 @@ mod repokit;
14
14
  mod validations;
15
15
 
16
16
  fn main() {
17
- let root = Executor::exec("git rev-parse --show-toplevel", |cmd| cmd);
17
+ let root = InternalFileSystem::find_root();
18
18
  let config = TypescriptCommand::new(&root).parse_configuration();
19
19
  let kit = RepoKit::new(root, config);
20
20
  kit.invoke();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repokit/core",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "A knowledgebase for your repository - wrapped in a CLI",
5
5
  "keywords": [
6
6
  "cli",