summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-04-03 23:35:14 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-04-03 23:35:14 +0900
commiteec1af1f52aa217e12e52c7c9d66f0106e66a200 (patch)
treec89a99e6d289c411f1457743776a9d097c9e6554 /src/tools
parentAPメンションはaudienceじゃなくてtagを参照するなど (#6128) (diff)
downloadsharkey-eec1af1f52aa217e12e52c7c9d66f0106e66a200.tar.gz
sharkey-eec1af1f52aa217e12e52c7c9d66f0106e66a200.tar.bz2
sharkey-eec1af1f52aa217e12e52c7c9d66f0106e66a200.zip
Revert
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/add-emoji.ts26
-rw-r--r--src/tools/index.ts8
-rw-r--r--src/tools/make-api-json.ts9
-rw-r--r--src/tools/mark-admin.ts18
-rw-r--r--src/tools/refresh-question.ts18
-rw-r--r--src/tools/resync-remote-user.ts34
-rw-r--r--src/tools/show-signin-history.ts39
7 files changed, 60 insertions, 92 deletions
diff --git a/src/tools/add-emoji.ts b/src/tools/add-emoji.ts
index 4f54b5b460..3745b48889 100644
--- a/src/tools/add-emoji.ts
+++ b/src/tools/add-emoji.ts
@@ -14,19 +14,17 @@ async function main(name: string, url: string, alias?: string): Promise<any> {
});
}
-export default () => {
- const args = process.argv.slice(3);
- const name = args[0];
- const url = args[1];
+const args = process.argv.slice(2);
+const name = args[0];
+const url = args[1];
- if (!name) throw new Error('require name');
- if (!url) throw new Error('require url');
+if (!name) throw new Error('require name');
+if (!url) throw new Error('require url');
- main(name, url).then(() => {
- console.log('success');
- process.exit(0);
- }).catch(e => {
- console.warn(e);
- process.exit(1);
- });
-}
+main(name, url).then(() => {
+ console.log('success');
+ process.exit(0);
+}).catch(e => {
+ console.warn(e);
+ process.exit(1);
+});
diff --git a/src/tools/index.ts b/src/tools/index.ts
deleted file mode 100644
index 0b59b547d8..0000000000
--- a/src/tools/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { initDb } from '../db/postgre';
-import 'reflect-metadata';
-
-console.log('Connecting DB...')
-initDb().then(() => {
- console.log('Connedted!')
- require(`./${process.argv[2]}`).default();
-});
diff --git a/src/tools/make-api-json.ts b/src/tools/make-api-json.ts
deleted file mode 100644
index a8b7559e8d..0000000000
--- a/src/tools/make-api-json.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { writeFileSync } from 'fs';
-import { join } from 'path';
-import { genOpenapiSpec } from '../server/api/openapi/gen-spec';
-
-export default () => {
- writeFileSync(join(__dirname, '../../built/client/assets/api.json'), JSON.stringify(genOpenapiSpec()));
- console.log('Done!');
- process.exit(0);
-};
diff --git a/src/tools/mark-admin.ts b/src/tools/mark-admin.ts
index b630dbe901..5844bb464e 100644
--- a/src/tools/mark-admin.ts
+++ b/src/tools/mark-admin.ts
@@ -21,14 +21,12 @@ async function main(username: string) {
}
}
-export default () => {
- const args = process.argv.slice(3);
+const args = process.argv.slice(2);
- main(args[0]).then(() => {
- console.log('Success');
- process.exit(0);
- }).catch(e => {
- console.error(`Error: ${e.message || e}`);
- process.exit(1);
- });
-}
+main(args[0]).then(() => {
+ console.log('Success');
+ process.exit(0);
+}).catch(e => {
+ console.error(`Error: ${e.message || e}`);
+ process.exit(1);
+});
diff --git a/src/tools/refresh-question.ts b/src/tools/refresh-question.ts
index ff849aed7f..83d71ff303 100644
--- a/src/tools/refresh-question.ts
+++ b/src/tools/refresh-question.ts
@@ -4,15 +4,11 @@ async function main(uri: string): Promise<any> {
return await updateQuestion(uri);
}
-export default () => {
- const args = process.argv.slice(3);
- const uri = args[0];
+const args = process.argv.slice(2);
+const uri = args[0];
- main(uri).then(result => {
- console.log(`Done: ${result}`);
- process.exit(0);
- }).catch(e => {
- console.warn(e);
- process.exit(1);
- });
-}
+main(uri).then(result => {
+ console.log(`Done: ${result}`);
+}).catch(e => {
+ console.warn(e);
+});
diff --git a/src/tools/resync-remote-user.ts b/src/tools/resync-remote-user.ts
index c30b645725..c9d1ed588c 100644
--- a/src/tools/resync-remote-user.ts
+++ b/src/tools/resync-remote-user.ts
@@ -6,26 +6,22 @@ async function main(acct: string): Promise<any> {
await resolveUser(username, host, {}, true);
}
-export default () => {
- // get args
- const args = process.argv.slice(3);
- let acct = args[0];
+// get args
+const args = process.argv.slice(2);
+let acct = args[0];
- // normalize args
- acct = acct.replace(/^@/, '');
+// normalize args
+acct = acct.replace(/^@/, '');
- // check args
- if (!acct.match(/^\w+@\w/)) {
- throw `Invalid acct format. Valid format are user@host`;
- }
+// check args
+if (!acct.match(/^\w+@\w/)) {
+ throw `Invalid acct format. Valid format are user@host`;
+}
- console.log(`resync ${acct}`);
+console.log(`resync ${acct}`);
- main(acct).then(() => {
- console.log('Done');
- process.exit(0);
- }).catch(e => {
- console.warn(e);
- process.exit(1);
- });
-}
+main(acct).then(() => {
+ console.log('Done');
+}).catch(e => {
+ console.warn(e);
+});
diff --git a/src/tools/show-signin-history.ts b/src/tools/show-signin-history.ts
index 233b97a790..fd7cd39e38 100644
--- a/src/tools/show-signin-history.ts
+++ b/src/tools/show-signin-history.ts
@@ -1,12 +1,12 @@
import { Users, Signins } from '../models';
-// node built/tools/ show-signin-history username
+// node built/tools/show-signin-history username
// => {Success} {Date} {IPAddrsss}
-// node built/tools/ show-signin-history username user-agent,x-forwarded-for
+// node built/tools/show-signin-history username user-agent,x-forwarded-for
// with user-agent and x-forwarded-for
-// node built/tools/ show-signin-history username all
+// node built/tools/show-signin-history username all
// with full request headers
async function main(username: string, headers?: string[]) {
@@ -35,25 +35,22 @@ async function main(username: string, headers?: string[]) {
}
}
-export default () => {
- // get args
- const args = process.argv.slice(3);
+// get args
+const args = process.argv.slice(2);
- let username = args[0];
- let headers: string[] | undefined;
+let username = args[0];
+let headers: string[] | undefined;
- if (args[1] != null) {
- headers = args[1].split(/,/).map(header => header.toLowerCase());
- }
-
- // normalize args
- username = username.replace(/^@/, '');
-
- main(username, headers).then(() => {
- process.exit(0);
- }).catch(e => {
- console.warn(e);
- process.exit(1);
- });
+if (args[1] != null) {
+ headers = args[1].split(/,/).map(header => header.toLowerCase());
}
+// normalize args
+username = username.replace(/^@/, '');
+
+main(username, headers).then(() => {
+ process.exit(0);
+}).catch(e => {
+ console.warn(e);
+ process.exit(1);
+});