feat: use embedded filesystem for default files
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
97a05896a3
commit
d39d597128
5 changed files with 26 additions and 28 deletions
|
@ -17,5 +17,5 @@ output_path: null
|
||||||
prompt:
|
prompt:
|
||||||
header_path: null
|
header_path: null
|
||||||
footer_path: null
|
footer_path: null
|
||||||
template_path: misc/templates/default.j2
|
template_path: null
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
version: 2.0
|
version: 2.0
|
||||||
shards:
|
shards:
|
||||||
|
baked_file_system:
|
||||||
|
git: https://github.com/schovi/baked_file_system.git
|
||||||
|
version: 0.10.0
|
||||||
|
|
||||||
crinja:
|
crinja:
|
||||||
git: https://github.com/straight-shoota/crinja.git
|
git: https://github.com/straight-shoota/crinja.git
|
||||||
version: 0.8.1
|
version: 0.8.1
|
||||||
|
|
|
@ -18,6 +18,9 @@ dependencies:
|
||||||
github: alexherbo2/walk.cr
|
github: alexherbo2/walk.cr
|
||||||
version_from_shard:
|
version_from_shard:
|
||||||
github: hugopl/version_from_shard
|
github: hugopl/version_from_shard
|
||||||
|
baked_file_system:
|
||||||
|
github: schovi/baked_file_system
|
||||||
|
version: 0.10.0
|
||||||
# completion:
|
# completion:
|
||||||
# github: f/completion
|
# github: f/completion
|
||||||
|
|
||||||
|
|
36
src/cli.cr
36
src/cli.cr
|
@ -6,6 +6,7 @@ require "crinja"
|
||||||
|
|
||||||
require "./config"
|
require "./config"
|
||||||
require "./filelist"
|
require "./filelist"
|
||||||
|
require "./file_storage"
|
||||||
|
|
||||||
# The CodePreloader module organizes classes and methods related to preloading code files.
|
# The CodePreloader module organizes classes and methods related to preloading code files.
|
||||||
module CodePreloader
|
module CodePreloader
|
||||||
|
@ -40,35 +41,14 @@ module CodePreloader
|
||||||
abort("Unexpected nil value for init_options!") if init_options.nil?
|
abort("Unexpected nil value for init_options!") if init_options.nil?
|
||||||
|
|
||||||
# Default path for the .code_preloader.yml file
|
# Default path for the .code_preloader.yml file
|
||||||
default_config_path = "example.code_preloader.yml"
|
default_config_path = ".code_preloader.yml"
|
||||||
|
|
||||||
# Use the specified path if provided, otherwise use the default
|
# Use the specified path if provided, otherwise use the default
|
||||||
config_path = init_options.config_path || default_config_path
|
config_path = init_options.config_path || default_config_path
|
||||||
|
abort("ERROR: configuration file already exist: #{config_path}") if File.exists? config_path
|
||||||
|
|
||||||
# Content of the .code_preloader.yml file
|
# Content of the default .code_preloader.yml file
|
||||||
config_content = [
|
config_content = FileStorage.get("default_config.yml").gets_to_end
|
||||||
"---",
|
|
||||||
"# Example configuration for Code-Preloader",
|
|
||||||
"",
|
|
||||||
"# List of repository paths to preload",
|
|
||||||
"# source_list:",
|
|
||||||
"# - \"path/to/repo1\"",
|
|
||||||
"# - \"path/to/repo2\"",
|
|
||||||
"",
|
|
||||||
"# List of patterns to ignore during preloading",
|
|
||||||
"ignore_list:",
|
|
||||||
" - ^\\.git/.*",
|
|
||||||
"",
|
|
||||||
"# Path to the output file (if null, output to STDOUT)",
|
|
||||||
"output_path: null",
|
|
||||||
"",
|
|
||||||
"# Optional: Path to a file containing the header prompt",
|
|
||||||
"header_path: null",
|
|
||||||
"",
|
|
||||||
"# Optional: Path to a file containing the footer prompt",
|
|
||||||
"footer_path: null",
|
|
||||||
""
|
|
||||||
].join("\n")
|
|
||||||
|
|
||||||
# Writing the configuration content to the file
|
# Writing the configuration content to the file
|
||||||
File.write(config_path, config_content)
|
File.write(config_path, config_content)
|
||||||
|
@ -116,8 +96,12 @@ module CodePreloader
|
||||||
filelist.reject { |path| !!(path =~ Regex.new(ignore_pattern)) }
|
filelist.reject { |path| !!(path =~ Regex.new(ignore_pattern)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
abort("No prompt file defined!") if prompt_template_path.nil?
|
STDERR.puts "Loading template file from: #{prompt_template_path ? prompt_template_path : "<internal>" }".colorize(:yellow)
|
||||||
|
if prompt_template_path
|
||||||
prompt_template_content = File.read(prompt_template_path)
|
prompt_template_content = File.read(prompt_template_path)
|
||||||
|
else
|
||||||
|
prompt_template_content = FileStorage.get("default_template.j2").gets_to_end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if !prompt_header_path.nil?
|
if !prompt_header_path.nil?
|
||||||
|
|
7
src/file_storage.cr
Normal file
7
src/file_storage.cr
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
require "baked_file_system"
|
||||||
|
|
||||||
|
class FileStorage
|
||||||
|
extend BakedFileSystem
|
||||||
|
|
||||||
|
bake_folder "../static"
|
||||||
|
end
|
Loading…
Reference in a new issue