/[sudobot]/trunk/scripts/make-service.js
ViewVC logotype

Contents of /trunk/scripts/make-service.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 575 - (show annotations)
Mon Jul 29 17:59:26 2024 UTC (8 months ago) by rakinar2
File MIME type: text/javascript
File size: 2507 byte(s)
chore: add trunk
1 #!/usr/bin/env node
2
3 /*
4 * This file is part of SudoBot.
5 *
6 * Copyright (C) 2021-2023 OSN Developers.
7 *
8 * SudoBot is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * SudoBot is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 const fs = require("fs");
23 const path = require("path");
24
25 if (process.argv.length < 3) {
26 console.log("A service name and type is required to generate!");
27 process.exit(-1);
28 }
29
30 if (process.argv.length < 4) {
31 console.log("A service name is required to generate!");
32 process.exit(-1);
33 }
34
35 if (process.argv[2] !== "automod" && process.argv[2] !== "services") {
36 console.log("Invalid service type!");
37 process.exit(-1);
38 }
39
40 const template = `/**
41 * This file is part of SudoBot.
42 *
43 * Copyright (C) 2021-${new Date().getFullYear()} OSN Developers.
44 *
45 * SudoBot is free software; you can redistribute it and/or modify it
46 * under the terms of the GNU Affero General Public License as published by
47 * the Free Software Foundation, either version 3 of the License, or
48 * (at your option) any later version.
49 *
50 * SudoBot is distributed in the hope that it will be useful, but
51 * WITHOUT ANY WARRANTY; without even the implied warranty of
52 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53 * GNU Affero General Public License for more details.
54 *
55 * You should have received a copy of the GNU Affero General Public License
56 * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
57 */
58
59 import Service from "../core/Service";
60
61 export const name = "%NAME_LOWERCASE%";
62
63 export default class %NAME%Service extends Service {
64
65 }
66 `
67 .replace("%NAME%", process.argv[3])
68 .replace("%NAME_LOWERCASE%", process.argv[3].toLowerCase());
69
70 fs.writeFileSync(
71 path.join(
72 __dirname,
73 fs.existsSync(path.join(__dirname, "src")) ? "." : "..",
74 "src",
75 process.argv[2],
76 process.argv[3] + "Service.ts"
77 ),
78 template
79 );
80 console.log("Successfully created: ", process.argv[3] + "Service");

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26