dorky 2.1.8 → 2.2.1

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.
Files changed (3) hide show
  1. package/README.md +7 -0
  2. package/bin/index.js +45 -17
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -84,5 +84,12 @@ Anyhow, we shall store it on a private storage, using **dorky**, that stores it
84
84
 
85
85
  ## To-Do
86
86
 
87
+ [*] List remote files in dorky bucket.
88
+ [*] Auto detect .env and .config files.
89
+ [ ] Handle errors.
90
+ [ ] Extension for VS Code to list and highlight them like git.
91
+ [ ] Unintialize dorky setup.
92
+ [ ] MCP server.
93
+ [ ] Encryption of files.
87
94
  [ ] Add stages for variables.
88
95
 
package/bin/index.js CHANGED
@@ -38,7 +38,6 @@ console.log(chalk.bgHex(randomColor)(usage));
38
38
  if (process.argv.slice(2).length === 0) {
39
39
  process.argv.push("--help");
40
40
  }
41
-
42
41
  var args = yargs
43
42
  .option("init", { alias: "i", describe: "Initialize dorky project", type: "string", demandOption: false })
44
43
  .option("list", { alias: "l", describe: "List files in dorky", type: "string", demandOption: false })
@@ -47,6 +46,15 @@ var args = yargs
47
46
  .option("push", { alias: "ph", describe: "Push files to storage", type: "string", demandOption: false })
48
47
  .option("pull", { alias: "pl", describe: "Pull files from storage", type: "string", demandOption: false })
49
48
  .option("migrate", { alias: "m", describe: "Migrate dorky project to another storage", type: "string", demandOption: false })
49
+ .example('$0 --init aws', 'Initialize a dorky project with AWS storage')
50
+ .example('$0 --init google-drive', 'Initialize a dorky project with Google Drive storage')
51
+ .example('$0 --list', 'List local files that can be added and already added files')
52
+ .example('$0 --list remote', 'List files in remote storage')
53
+ .example('$0 --add file1.txt file2.js', 'Add specific files to stage-1')
54
+ .example('$0 --rm file1.txt', 'Remove a file from stage-1')
55
+ .example('$0 --push', 'Push staged files to storage')
56
+ .example('$0 --pull', 'Pull files from storage')
57
+ .example('$0 --migrate aws', 'Migrate the project to AWS storage')
50
58
  .help('help')
51
59
  .strict()
52
60
  .argv
@@ -118,24 +126,44 @@ async function init(storage) {
118
126
  }
119
127
  }
120
128
 
121
- async function list() {
129
+ async function list(type) {
122
130
  checkIfDorkyProject();
123
- console.log(chalk.red("Listing files that can be added:"));
124
- var exclusions = fs.readFileSync(".dorkyignore").toString().split(EOL);
125
- exclusions = exclusions.filter((exclusion) => exclusion !== "");
126
- const src = process.cwd();
127
- const files = await glob(path.join(src, "**/*"), { dot: true });
128
- const filteredFiles = files.filter((file) => {
129
- for (let i = 0; i < exclusions.length; i++) {
130
- if (file.includes(exclusions[i])) return false;
131
- }
132
- return true;
133
- });
134
- filteredFiles.forEach((file) => console.log(chalk.red(`- ${path.relative(process.cwd(), file)}`)));
135
- console.log(chalk.green("\nList of files that are already added:"));
136
131
  const metaData = JSON.parse(fs.readFileSync(".dorky/metadata.json"));
137
- const addedFiles = Object.keys(metaData["stage-1-files"]);
138
- addedFiles.forEach((file) => console.log(chalk.green(`- ${file}`)));
132
+ switch (type) {
133
+ case "remote":
134
+ const uploadedFiles = Object.keys(metaData["uploaded-files"]);
135
+ if (uploadedFiles.length === 0) {
136
+ console.log(chalk.red("No files found in remote storage."));
137
+ return;
138
+ }
139
+ console.log(chalk.green("Listing files in stage-1:"));
140
+ uploadedFiles.forEach((file) => console.log(chalk.green(`- ${file}`)));
141
+ break;
142
+ default:
143
+ console.log(chalk.red("Listing files that can be added:"));
144
+ var exclusions = fs.readFileSync(".dorkyignore").toString().split(EOL);
145
+ exclusions = exclusions.filter((exclusion) => exclusion !== "");
146
+ const src = process.cwd();
147
+ const files = await glob(path.join(src, "**/*"), { dot: true });
148
+ const filteredFiles = files.filter((file) => {
149
+ for (let i = 0; i < exclusions.length; i++) {
150
+ if (file.includes(exclusions[i])) return false;
151
+ }
152
+ return true;
153
+ });
154
+ filteredFiles.forEach((file) => {
155
+ const relativePath = path.relative(process.cwd(), file);
156
+ if (relativePath.includes('.env') || relativePath.includes('.config')) {
157
+ console.log(chalk.bold.bgYellowBright.red(`- ${relativePath} (This file might be sensitive, please add it to dorky if needed)`));
158
+ } else {
159
+ console.log(chalk.red(`- ${relativePath}`));
160
+ }
161
+ });
162
+ console.log(chalk.green("\nList of files that are already added:"));
163
+ const addedFiles = Object.keys(metaData["stage-1-files"]);
164
+ addedFiles.forEach((file) => console.log(chalk.green(`- ${file}`)));
165
+ break;
166
+ }
139
167
  }
140
168
 
141
169
  function add(listOfFiles) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dorky",
3
- "version": "2.1.8",
3
+ "version": "2.2.1",
4
4
  "description": "DevOps Records Keeper.",
5
5
  "bin": {
6
6
  "dorky": "bin/index.js"