summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2020-04-03 17:13:41 +0900
committertamaina <tamaina@hotmail.co.jp>2020-04-03 17:13:41 +0900
commit795fb0eb60ea475533b1d9a12182030f93f01cac (patch)
treec42e570047d1e67108d7bb1f8bd5c9fd165bbb1b /src/tools
parentfeat(streaming): Add emoji added event (diff)
downloadsharkey-795fb0eb60ea475533b1d9a12182030f93f01cac.tar.gz
sharkey-795fb0eb60ea475533b1d9a12182030f93f01cac.tar.bz2
sharkey-795fb0eb60ea475533b1d9a12182030f93f01cac.zip
Pre-render ReDoc
redoc-cliはexpandResponsesは200のみとすると数値と認識されてしまい設定できないため202,204という指定にしています
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/add-emoji.ts30
-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.ts20
-rw-r--r--src/tools/resync-remote-user.ts40
-rw-r--r--src/tools/show-signin-history.ts39
7 files changed, 98 insertions, 66 deletions
diff --git a/src/tools/add-emoji.ts b/src/tools/add-emoji.ts
index 3745b48889..911108b045 100644
--- a/src/tools/add-emoji.ts
+++ b/src/tools/add-emoji.ts
@@ -14,17 +14,19 @@ async function main(name: string, url: string, alias?: string): Promise<any> {
});
}
-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');
-
-main(name, url).then(() => {
- console.log('success');
- process.exit(0);
-}).catch(e => {
- console.warn(e);
- process.exit(1);
-});
+export default () => {
+ const args = process.argv.slice(3);
+ const name = args[0];
+ const url = args[1];
+
+ 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);
+ });
+}
diff --git a/src/tools/index.ts b/src/tools/index.ts
new file mode 100644
index 0000000000..0b59b547d8
--- /dev/null
+++ b/src/tools/index.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..a8b7559e8d
--- /dev/null
+++ b/src/tools/make-api-json.ts
@@ -0,0 +1,9 @@
+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 5844bb464e..b630dbe901 100644
--- a/src/tools/mark-admin.ts
+++ b/src/tools/mark-admin.ts
@@ -21,12 +21,14 @@ async function main(username: string) {
}
}
-const args = process.argv.slice(2);
+export default () => {
+ const args = process.argv.slice(3);
-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 83d71ff303..5104590bf4 100644
--- a/src/tools/refresh-question.ts
+++ b/src/tools/refresh-question.ts
@@ -4,11 +4,15 @@ async function main(uri: string): Promise<any> {
return await updateQuestion(uri);
}
-const args = process.argv.slice(2);
-const uri = args[0];
-
-main(uri).then(result => {
- console.log(`Done: ${result}`);
-}).catch(e => {
- console.warn(e);
-});
+export default () => {
+ const args = process.argv.slice(3);
+ const uri = args[0];
+
+ main(uri).then(result => {
+ console.log(`Done: ${result}`);
+ process.exit(0);
+ }).catch(e => {
+ console.warn(e);
+ process.exit(1);
+ });
+}
diff --git a/src/tools/resync-remote-user.ts b/src/tools/resync-remote-user.ts
index c9d1ed588c..497bb89f36 100644
--- a/src/tools/resync-remote-user.ts
+++ b/src/tools/resync-remote-user.ts
@@ -6,22 +6,26 @@ async function main(acct: string): Promise<any> {
await resolveUser(username, host, {}, true);
}
-// get args
-const args = process.argv.slice(2);
-let acct = args[0];
-
-// normalize args
-acct = acct.replace(/^@/, '');
-
-// check args
-if (!acct.match(/^\w+@\w/)) {
- throw `Invalid acct format. Valid format are user@host`;
+export default () => {
+ // get args
+ const args = process.argv.slice(3);
+ let acct = args[0];
+
+ // normalize args
+ acct = acct.replace(/^@/, '');
+
+ // check args
+ if (!acct.match(/^\w+@\w/)) {
+ throw `Invalid acct format. Valid format are user@host`;
+ }
+
+ console.log(`resync ${acct}`);
+
+ main(acct).then(() => {
+ console.log('Done');
+ process.exit(0);
+ }).catch(e => {
+ console.warn(e);
+ process.exit(1);
+ });
}
-
-console.log(`resync ${acct}`);
-
-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 fd7cd39e38..233b97a790 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,22 +35,25 @@ async function main(username: string, headers?: string[]) {
}
}
-// get args
-const args = process.argv.slice(2);
+export default () => {
+ // get args
+ const args = process.argv.slice(3);
-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());
-}
+ if (args[1] != null) {
+ headers = args[1].split(/,/).map(header => header.toLowerCase());
+ }
+
+ // normalize args
+ username = username.replace(/^@/, '');
-// normalize args
-username = username.replace(/^@/, '');
+ main(username, headers).then(() => {
+ process.exit(0);
+ }).catch(e => {
+ console.warn(e);
+ process.exit(1);
+ });
+}
-main(username, headers).then(() => {
- process.exit(0);
-}).catch(e => {
- console.warn(e);
- process.exit(1);
-});