1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const command_1 = require("@oclif/command");
|
4 | const dotenv = require("dotenv");
|
5 | const fse = require("fs-extra");
|
6 | const path = require("path");
|
7 | const YAML = require("yaml");
|
8 | class Base extends command_1.Command {
|
9 | root_folder_path() {
|
10 | return path.resolve(path.dirname(require.main.filename || process.mainModule.filename), '..');
|
11 | }
|
12 | config_folder_path() {
|
13 | return path.join(this.root_folder_path(), 'config');
|
14 | }
|
15 | icon_folder_path(icon_file_name) {
|
16 | return path.join(this.root_folder_path(), 'icon', icon_file_name);
|
17 | }
|
18 |
|
19 | system_default_env_file_path() {
|
20 | return path.join(this.config_folder_path(), 'aral.env');
|
21 | }
|
22 | system_env_file_path() {
|
23 | return path.join(this.config.configDir, 'aral.env');
|
24 | }
|
25 | system_env_config() {
|
26 | try {
|
27 | fse.accessSync(this.system_env_file_path());
|
28 | }
|
29 | catch (err) {
|
30 | this.warn('maybe ARAL was not initialized');
|
31 | this.warn('try running aral init');
|
32 | this.error(err);
|
33 | }
|
34 | return dotenv.parse(fse.readFileSync(this.system_env_file_path()));
|
35 | }
|
36 | system_docker_compose_file_path() {
|
37 | return path.join(this.config_folder_path(), 'aral.yml');
|
38 | }
|
39 |
|
40 | project_icon_path() {
|
41 | return path.join(process.cwd(), this.project_env_config()['PROJECT_ICON']);
|
42 | }
|
43 | project_env_file_path() {
|
44 | return path.join(process.cwd(), 'aral.env');
|
45 | }
|
46 | project_env_config() {
|
47 | try {
|
48 | fse.accessSync(this.project_docker_compose_file_path());
|
49 | fse.accessSync(this.project_env_file_path());
|
50 | }
|
51 | catch (err) {
|
52 | this.warn('Maybe you are not in project root folder');
|
53 | this.warn('You are here: ' + process.cwd());
|
54 | this.error(err);
|
55 | }
|
56 | return dotenv.parse(fse.readFileSync(this.project_env_file_path()));
|
57 | }
|
58 | project_import_file_path() {
|
59 | return path.join(process.cwd(), 'aral.dev.import.yml');
|
60 | }
|
61 | project_import_config() {
|
62 | try {
|
63 | fse.accessSync(this.project_import_file_path());
|
64 | }
|
65 | catch (err) {
|
66 | this.warn('Maybe you are not in project root folder');
|
67 | this.warn('You are here: ' + process.cwd());
|
68 | this.error(err);
|
69 | }
|
70 | let temp;
|
71 | try {
|
72 | temp = YAML.parse(fse.readFileSync(this.project_import_file_path()).toString());
|
73 | }
|
74 | catch (err) {
|
75 | this.warn('Maybe you are not in project root folder');
|
76 | this.error(err);
|
77 | }
|
78 | return temp;
|
79 | }
|
80 | project_docker_compose_file_path() {
|
81 | return path.join(process.cwd(), 'aral.dev.yml');
|
82 | }
|
83 | }
|
84 | exports.default = Base;
|