slack-cleaner 0.1.0 → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +17 -1
- package/package.json +2 -2
- package/src/cli/help.js +2 -0
- package/src/cli.js +7 -1
- package/test/env.test.js +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Gasperoni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -10,8 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
|
+
Install from npm (published package):
|
|
14
|
+
|
|
13
15
|
```bash
|
|
14
|
-
npm install
|
|
16
|
+
npm install -g slack-cleaner
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Alternatively check out the repo:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
gh repo clone mcdado/slack-cleaner-node
|
|
23
|
+
cd slack-cleaner-node
|
|
15
24
|
npm link
|
|
16
25
|
```
|
|
17
26
|
|
|
@@ -26,6 +35,13 @@ slack-cleaner --help
|
|
|
26
35
|
Use a token that can read history and delete the target messages.
|
|
27
36
|
|
|
28
37
|
This CLI auto-loads a `.env` file from your current working directory.
|
|
38
|
+
If not present there, it also checks `.env` in the installed package directory
|
|
39
|
+
(useful when running a globally linked install via `npm link`).
|
|
40
|
+
|
|
41
|
+
Token setup by install mode:
|
|
42
|
+
|
|
43
|
+
- `npm link` (repo checked out): put token in repo `.env` and it will be picked up as fallback.
|
|
44
|
+
- `npm install -g slack-cleaner` (no repo checkout): use either a `.env` in the directory where you run `slack-cleaner`, shell env vars, or `--token`.
|
|
29
45
|
|
|
30
46
|
Create it from the example:
|
|
31
47
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slack-cleaner",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Flag-based Slack message cleaner CLI for Node.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
"url": "https://github.com/mcdado/slack-cleaner-node/issues"
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/mcdado/slack-cleaner-node#readme"
|
|
38
|
-
}
|
|
38
|
+
}
|
package/src/cli/help.js
CHANGED
|
@@ -25,6 +25,8 @@ Execution:
|
|
|
25
25
|
|
|
26
26
|
Environment:
|
|
27
27
|
The CLI auto-loads .env in the current working directory.
|
|
28
|
+
If not set there, it also checks .env in the installed package directory.
|
|
29
|
+
For npm install -g usage, prefer cwd .env, shell env vars, or --token.
|
|
28
30
|
SLACK_USER_TOKEN, SLACK_BOT_TOKEN, or SLACK_TOKEN can be used instead of --token.
|
|
29
31
|
`);
|
|
30
32
|
}
|
package/src/cli.js
CHANGED
|
@@ -20,7 +20,13 @@ const { createDeletionProgressReporter } = require('./output/progress');
|
|
|
20
20
|
* @returns {Promise<void>}
|
|
21
21
|
*/
|
|
22
22
|
async function run(argv) {
|
|
23
|
-
|
|
23
|
+
const cwdEnvPath = path.resolve(process.cwd(), '.env');
|
|
24
|
+
const packageRootEnvPath = path.resolve(__dirname, '..', '.env');
|
|
25
|
+
|
|
26
|
+
loadDotEnv(cwdEnvPath);
|
|
27
|
+
if (packageRootEnvPath !== cwdEnvPath) {
|
|
28
|
+
loadDotEnv(packageRootEnvPath);
|
|
29
|
+
}
|
|
24
30
|
|
|
25
31
|
const args = parseArgs(argv);
|
|
26
32
|
const tokens = resolveTokens(args.token);
|
package/test/env.test.js
CHANGED
|
@@ -58,3 +58,19 @@ test('resolveTokens keeps ordered unique candidates', () => {
|
|
|
58
58
|
]);
|
|
59
59
|
assert.deepEqual(resolveTokens('user-token'), ['user-token', 'bot-token', 'generic-token']);
|
|
60
60
|
});
|
|
61
|
+
|
|
62
|
+
test('loadDotEnv does not override keys already set by earlier .env files', () => {
|
|
63
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'slack-cleaner-'));
|
|
64
|
+
const firstEnvPath = path.join(tmpDir, '.env.first');
|
|
65
|
+
const secondEnvPath = path.join(tmpDir, '.env.second');
|
|
66
|
+
|
|
67
|
+
fs.writeFileSync(firstEnvPath, 'SLACK_TOKEN=first-token\n', 'utf8');
|
|
68
|
+
fs.writeFileSync(secondEnvPath, 'SLACK_TOKEN=second-token\n', 'utf8');
|
|
69
|
+
|
|
70
|
+
delete process.env.SLACK_TOKEN;
|
|
71
|
+
|
|
72
|
+
loadDotEnv(firstEnvPath);
|
|
73
|
+
loadDotEnv(secondEnvPath);
|
|
74
|
+
|
|
75
|
+
assert.equal(process.env.SLACK_TOKEN, 'first-token');
|
|
76
|
+
});
|