bridge-compile
Advanced tools
Comparing version 1.0.19 to 1.0.20
@@ -7,2 +7,3 @@ #!/usr/bin/env node | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertJSONTypeToOpenAPI = void 0; | ||
const find_source_file_1 = require("./parser/find-source-file"); | ||
@@ -20,2 +21,3 @@ const fs_1 = __importDefault(require("fs")); | ||
const remove_added_code_1 = require("./parser/remove-added-code"); | ||
const openapi_1 = require("./openapi"); | ||
const hasProjectPNPM = (projectTempPath) => { | ||
@@ -62,2 +64,17 @@ try { | ||
}; | ||
const convertJSONTypeToOpenAPI = (jsonType) => { | ||
const openAPI = { | ||
openapi: '3.0.0', | ||
info: { | ||
title: 'Your API', | ||
version: '1.0.0', | ||
}, | ||
paths: {}, | ||
}; | ||
if (!('object' in jsonType)) | ||
return openAPI; | ||
openAPI.paths = (0, openapi_1.convertJSONTypeObjectToOpenAPIPath)(jsonType.object); | ||
return openAPI; | ||
}; | ||
exports.convertJSONTypeToOpenAPI = convertJSONTypeToOpenAPI; | ||
const launch = async () => { | ||
@@ -77,2 +94,5 @@ const packageJson = getPackageJSON(); | ||
const spinner = (0, ora_1.default)('Compiling your project').start(); | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Start Compilation | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
const { sourceFilePath, addedCode } = await (0, find_source_file_1.findSourceFilePath)('./'); | ||
@@ -82,3 +102,3 @@ if (!sourceFilePath) | ||
const JSONType = (0, ts_parser_1.default)(sourceFilePath); | ||
fs_1.default.writeFileSync('./JSONType.json', JSON.stringify(JSONType)); | ||
fs_1.default.writeFileSync('./JSONType.json', prettier_1.default.format(JSON.stringify(JSONType), { parser: 'json' })); | ||
(0, remove_added_code_1.removeAddedCode)(sourceFilePath, addedCode); | ||
@@ -88,2 +108,18 @@ const buffer = await (0, sdk_compilers_1.compileTypescriptSDK)(JSONType, bridgeConfig.serverUrl); | ||
zipFolder.extractAllTo('./sdk', true); | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// OPENAPI | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
const openAPI = { | ||
openapi: '3.0.0', | ||
info: { | ||
title: packageJson.name || 'Your Bridge API', | ||
version: packageJson.version || '1.0.0', | ||
}, | ||
paths: {}, | ||
}; | ||
openAPI.paths = (0, openapi_1.convertJSONTypeObjectToOpenAPIPath)(JSONType.object); | ||
fs_1.default.writeFileSync('./openapi.json', prettier_1.default.format(JSON.stringify(openAPI), { parser: 'json' })); | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Install Dependencies If needed | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
const installCommand = hasProjectPNPM('./') ? 'pnpm i' : 'npm i'; | ||
@@ -90,0 +126,0 @@ if (!packageJson.dependencies.axios) |
@@ -58,3 +58,2 @@ "use strict"; | ||
} | ||
// | ||
if (!('union' in value.object.return)) { | ||
@@ -61,0 +60,0 @@ if ('primitive' in value.object.return && value.object.return.primitive === 'void') |
@@ -20,1 +20,3 @@ "use strict"; | ||
__exportStar(require("./run-command"), exports); | ||
__exportStar(require("./statusCode"), exports); | ||
__exportStar(require("./methods"), exports); |
{ | ||
"name": "bridge-compile", | ||
"version": "1.0.19", | ||
"version": "1.0.20", | ||
"description": "Compile the sdk of your Bridge project with one command locally", | ||
@@ -5,0 +5,0 @@ "author": "Bridge Team <support@bridge.codes>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52816
27
1217