chimp
Version:
Your development companion for doing quality, faster.
61 lines (60 loc) • 2.63 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
// @ts-ignore
const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
const node_path_1 = tslib_1.__importDefault(require("node:path"));
// @ts-ignore
const wait_on_1 = tslib_1.__importDefault(require("wait-on"));
// @ts-ignore
const axios_1 = tslib_1.__importDefault(require("axios"));
const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
const node_child_process_1 = require("node:child_process");
function quietExec(command, options, errorMessage = '') {
const { stdout, stderr, code } = shelljs_1.default.exec(command, Object.assign({}, options));
if (code !== 0) {
throw new Error(`${errorMessage}: , ${stderr}`);
}
return stdout;
}
const pathToRunFrom = node_path_1.default.join(process.cwd(), '../');
quietExec('./chimp/bin/run create chimp-test-repo', { cwd: pathToRunFrom });
shelljs_1.default.cp('-R', './test-module', '../chimp-test-repo/src/modules/');
const pathToRunFromChimp = node_path_1.default.join(process.cwd(), '../chimp-test-repo');
shelljs_1.default.sed('-i', /"chimp": "0.0.0-development"/, '"chimp": "../chimp"', node_path_1.default.join(pathToRunFromChimp, 'package.json'));
quietExec('npm install', { cwd: pathToRunFromChimp });
quietExec('npm run type-check', { cwd: pathToRunFromChimp });
quietExec("npm run lint -- --rule 'jest/expect-expect: off'", { cwd: pathToRunFromChimp });
(0, node_child_process_1.spawn)('npm', ['start'], {
stdio: 'ignore',
detached: true,
cwd: pathToRunFromChimp,
}).unref();
const opts = {
resources: ['http://localhost:4000/graphql'],
validateStatus(status) {
return status >= 200 && status <= 405;
},
};
const checkGraphQl = async () => {
var _a, _b;
try {
await (0, wait_on_1.default)(opts);
}
catch (error) {
console.error('Error', error);
process.exit(1);
}
try {
const { data } = await axios_1.default.post('http://localhost:4000/graphql', {
query: '{ GetNumbers { one two three computed } }',
});
node_assert_1.default.deepStrictEqual((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.GetNumbers, { one: 1, two: null, three: 3, computed: '1 2 3' });
console.log('Looking good! Got:', (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.GetNumbers);
}
catch (error) {
console.error('Error', error);
process.exit(1);
}
};
checkGraphQl().then(() => ({}));
;