Update tsconfig.json files with resolveJsonModule option

This commit is contained in:
Simon Larsen
2024-04-08 14:03:07 +01:00
parent 11fd2d3c65
commit 1401daab06
21 changed files with 162 additions and 77 deletions

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -108,6 +109,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -108,6 +109,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -109,6 +110,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -1,50 +1,83 @@
#!/usr/bin/env tsx #!/usr/bin/env tsx
import yargs from 'yargs'; import yargs from 'yargs';
import MonitorInfrastructure from './Jobs/MonitorInfrastructure'; import { ChildProcess, spawn } from 'node:child_process';
import Logger from './Utils/Logger';
import PackageJson from './package.json';
export interface ArgumentType {
[x: string]: unknown;
k: string;
u: string | undefined;
_: (string | number)[];
$0: string;
}
let daemon: ChildProcess | null = null;
const usage: string = const usage: string =
'\nUsage: oneuptime-infrastructure-agent --secret-key <secret-key>'; '\nUsage: oneuptime-infrastructure-agent start --secret-key <secret-key>.';
const argv:
| { yargs
[x: string]: unknown; .scriptName('oneuptime-infrastructure-agent')
k: string;
u: string | undefined;
_: (string | number)[];
$0: string;
}
| Promise<{
[x: string]: unknown;
k: string;
u: string | undefined;
_: (string | number)[];
$0: string;
}> = yargs
.usage(usage) .usage(usage)
.option('k', { .version(PackageJson.version)
alias: 'secret-key', .command('start', 'Start the app as a daemon', (y: any) => {
describe:
'Secret Key for this agent. You will find this on OneUptime Dashboard', return y.option('k', {
type: 'string', alias: 'secret-key',
demandOption: true, describe:
'Secret Key for this agent. You will find this on OneUptime Dashboard',
type: 'string',
demandOption: true,
})
.option('u', {
alias: 'oneuptime-url',
describe: 'OneUptime Host. By default this is https://oneuptime.com',
type: 'string',
demandOption: false,
});
}, (y: any) => {
const argv = y.argv as ArgumentType;
// add secrt key and oneuptime url
const startArguments: Array<string> = ['Start.ts'];
if (argv['secret-key']) {
startArguments.push('--secret-key=' + argv['secret-key'].toString());
} else {
Logger.info('No --secret-key argument found. You can find secret key for this monitor on OneUptime Dashboard');
process.exit(1);
}
if (argv['oneuptime-url']) {
startArguments.push('--oneuptime-url=' + argv['oneuptime-url'].toString());
} else {
startArguments.push('--oneuptime-url=https://oneuptime.com');
}
daemon = spawn('tsx', startArguments, {
detached: true,
stdio: 'ignore'
});
daemon.unref();
Logger.info('OneUptime Infrastructure Agent started as daemon');
}) })
.option('u', { .command('stop', 'Stop the daemon', () => {
alias: 'oneuptime-url', if (daemon && daemon.pid) {
describe: 'OneUptime Host. By default this is https://oneuptime.com', process.kill(daemon.pid);
type: 'string', Logger.info('OneUptime Infrastructure Agent stopped');
demandOption: false, } else {
Logger.info('OneUptime Infrastructure Agent not running');
}
})
.command('$0', 'the default command', () => { }, (_) => {
yargs.showHelp();
}) })
.help(true).argv; .help(true).argv;
const secretKey: string | undefined = (argv as any)['secret-key'];
const oneuptimeHost: string =
(argv as any)['oneuptime-url'] || 'https://oneuptime.com';
if (!secretKey) {
throw new Error(
'No secret-key argument found. You can find secret key for this monitor on OneUptime Dashboard'
);
}
MonitorInfrastructure.initJob(secretKey, oneuptimeHost);

View File

@@ -0,0 +1,14 @@
import MonitorInfrastructure from "./Jobs/MonitorInfrastructure";
import { argv } from 'yargs';
const secretKey: string | undefined = (argv as any)['secret-key'];
const oneuptimeHost: string =
(argv as any)['oneuptime-url'] || 'https://oneuptime.com';
if (!secretKey) {
throw new Error(
'No secret-key argument found. You can find secret key for this monitor on OneUptime Dashboard'
);
}
MonitorInfrastructure.initJob(secretKey, oneuptimeHost);

View File

@@ -3,12 +3,13 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */ /* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Projects */ /* Projects */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -108,6 +109,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -108,6 +109,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "CommonJS" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -108,6 +109,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,7 +106,8 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
}, },
"include": ["/**/*.ts"], "include": ["/**/*.ts"],
"exclude": ["node_modules"] "exclude": ["node_modules"]

View File

@@ -4,7 +4,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -109,6 +110,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -108,6 +109,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }

View File

@@ -3,7 +3,8 @@
// these options are overrides used only by ts-node // these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": { "compilerOptions": {
"module": "commonjs" "module": "commonjs",
"resolveJsonModule": true,
} }
}, },
"compilerOptions": { "compilerOptions": {
@@ -105,6 +106,7 @@
/* Completeness */ /* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
"resolveJsonModule": true
} }
} }