@benshawmean/envedit 1.2.3 → 1.3.0

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,4 +1,4 @@
1
- import Commands from "./environment";
1
+ import Commands from "./environmentCmd";
2
2
 
3
3
  export default {
4
4
  command: 'environment',
@@ -11,7 +11,7 @@ export default {
11
11
  describe: 'Add a new environment',
12
12
  builder: (yargs) => yargs,
13
13
  handler: async (argv) => {
14
- const config = new Configuration().loadConfigurationFile();
14
+ const config = new Configuration().load();
15
15
  const logger = new Logger(argv.level);
16
16
 
17
17
  const name = await input({
@@ -45,7 +45,7 @@ export default {
45
45
 
46
46
  config
47
47
  .addEnvironment({ name, prefix, file, isActive })
48
- .saveConfigurationFile();
48
+ .save();
49
49
 
50
50
  const envFile = new EnvironmentFile(file).load();
51
51
 
@@ -11,7 +11,7 @@ export default {
11
11
  describe: 'Edit an environment',
12
12
  builder: (yargs) => yargs,
13
13
  handler: async (argv) => {
14
- const config = new Configuration().loadConfigurationFile();
14
+ const config = new Configuration().load();
15
15
  const logger = new Logger(argv.level);
16
16
 
17
17
  const name = await select({
@@ -65,7 +65,7 @@ export default {
65
65
 
66
66
  config
67
67
  .editEnvironment(name, updatedEnv)
68
- .saveConfigurationFile();
68
+ .save();
69
69
 
70
70
  if (itemsToEdit.includes("file") && fs.existsSync(selectedEnv.file)) {
71
71
  logger.debug(`Old environment file found: ${selectedEnv.file}`);
@@ -6,7 +6,7 @@ export default {
6
6
  describe: 'List all environments',
7
7
  builder: (yargs) => yargs,
8
8
  handler: async (argv) => {
9
- const config = new Configuration().loadConfigurationFile();
9
+ const config = new Configuration().load();
10
10
  const logger = new Logger(argv.level);
11
11
 
12
12
  logger.debug(`Listing all environments`);
@@ -11,7 +11,7 @@ export default {
11
11
  describe: 'Remove an environment',
12
12
  builder: (yargs) => yargs,
13
13
  handler: async (argv) => {
14
- const config = new Configuration().loadConfigurationFile();
14
+ const config = new Configuration().load();
15
15
  const logger = new Logger(argv.level);
16
16
 
17
17
  const name = await select({
@@ -32,7 +32,7 @@ export default {
32
32
 
33
33
  config
34
34
  .removeEnvironment(name)
35
- .saveConfigurationFile();
35
+ .save();
36
36
 
37
37
  if (fs.existsSync(selectedEnv.file)) {
38
38
  const toDelete = await confirm({
package/cmd/setup.ts CHANGED
@@ -13,7 +13,7 @@ export default {
13
13
  handler: async (argv) => {
14
14
  const logger = new Logger(argv.level);
15
15
 
16
- new Configuration().loadConfigurationFile();
16
+ new Configuration().load();
17
17
 
18
18
  if (fs.existsSync('.git')) {
19
19
  logger.debug(`Git repository found. Checking for git ignore file.`);
package/cmd/use.ts CHANGED
@@ -14,7 +14,7 @@ export default {
14
14
  handler: async (argv) => {
15
15
  const logger = new Logger(argv.level);
16
16
 
17
- const config = new Configuration().loadConfigurationFile();
17
+ const config = new Configuration().load();
18
18
 
19
19
  const name = await select({
20
20
  message: "Select the environment to use",
@@ -40,7 +40,7 @@ export default {
40
40
  env.isActive = env.name === name;
41
41
  }
42
42
 
43
- config.saveConfigurationFile();
43
+ config.save();
44
44
  }
45
45
 
46
46
  logger.debug(`Creating symlink to environment file: ${selectedEnv.file}`);
package/cmd/variable.ts CHANGED
@@ -1,4 +1,4 @@
1
- import Commands from "./variable";
1
+ import Commands from "./variableCmd";
2
2
 
3
3
  export default {
4
4
  command: 'variable',
@@ -9,7 +9,7 @@ export default {
9
9
  describe: 'Add a new environment variable',
10
10
  builder: (yargs) => yargs,
11
11
  handler: async (argv) => {
12
- const config = new Configuration().loadConfigurationFile();
12
+ const config = new Configuration().load();
13
13
  const logger = new Logger(argv.level);
14
14
 
15
15
  const name = await input({
@@ -37,7 +37,7 @@ export default {
37
37
 
38
38
  config
39
39
  .addVariable({ name, type })
40
- .saveConfigurationFile();
40
+ .save();
41
41
 
42
42
  const shouldGloballySet = await confirm({
43
43
  message: "Do you want to set this variable with a global value for all environments?",
@@ -9,7 +9,7 @@ export default {
9
9
  describe: 'Edit an environment variable',
10
10
  builder: (yargs) => yargs,
11
11
  handler: async (argv) => {
12
- const config = new Configuration().loadConfigurationFile();
12
+ const config = new Configuration().load();
13
13
  const logger = new Logger(argv.level);
14
14
 
15
15
  const name = await select({
@@ -82,7 +82,7 @@ export default {
82
82
 
83
83
  config
84
84
  .editVariable(name, updatedVariable)
85
- .saveConfigurationFile();
85
+ .save();
86
86
  } else {
87
87
  logger.debug(`Adding editing variable value for: ${name}`);
88
88
 
@@ -7,7 +7,7 @@ export default {
7
7
  describe: 'List all environment variables',
8
8
  builder: (yargs) => yargs,
9
9
  handler: async (argv) => {
10
- const config = new Configuration().loadConfigurationFile();
10
+ const config = new Configuration().load();
11
11
  const logger = new Logger(argv.level);
12
12
 
13
13
  const activeEnv = config.getActiveEnvironment();
@@ -9,7 +9,7 @@ export default {
9
9
  describe: 'Remove an environment variable',
10
10
  builder: (yargs) => yargs,
11
11
  handler: async (argv) => {
12
- const config = new Configuration().loadConfigurationFile();
12
+ const config = new Configuration().load();
13
13
  const logger = new Logger(argv.level);
14
14
 
15
15
  const name = await select({
@@ -28,7 +28,7 @@ export default {
28
28
 
29
29
  config
30
30
  .removeVariable(name)
31
- .saveConfigurationFile();
31
+ .save();
32
32
 
33
33
  for (const env of config.configuration.environments) {
34
34
  const envFile = new EnvironmentFile(env.file).load();
package/lib/config.ts CHANGED
@@ -53,7 +53,7 @@ export class Configuration {
53
53
  };
54
54
  }
55
55
 
56
- public loadConfigurationFile() {
56
+ public load() {
57
57
  if (!fs.existsSync(this.configFilePath)) {
58
58
  logger.info(`Configuration file not found: ${this.configFilePath}`);
59
59
  logger.info(`Creating a new configuration file`);
@@ -64,7 +64,7 @@ export class Configuration {
64
64
  config.importFromEnv(fs.readFileSync('.env', "utf-8"));
65
65
  }
66
66
 
67
- this.saveConfigurationFile();
67
+ this.save();
68
68
  }
69
69
 
70
70
  const configContent = Bun.YAML.parse(fs.readFileSync(this.configFilePath, "utf-8")) as GeneralConfiguration;
@@ -75,7 +75,7 @@ export class Configuration {
75
75
  return this;
76
76
  }
77
77
 
78
- public saveConfigurationFile() {
78
+ public save() {
79
79
  fs.writeFileSync(
80
80
  this.configFilePath,
81
81
  Bun.YAML.stringify(this.configuration, null, 2),
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@benshawmean/envedit",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "1.2.3",
5
+ "version": "1.3.0",
6
6
  "license": "GPL-3.0-only",
7
7
  "bin": {
8
8
  "envedit": "index.ts"
File without changes
File without changes