Skip to content

Commit

Permalink
Update script
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcloudquery committed Oct 5, 2024
1 parent e61d699 commit 574e149
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"bin": {
"create-app": "./dist/scripts/generate-cloud-config-ui.mjs"
"create-app": "./dist/scripts/generate-cloud-config-ui.js"
},
"exports": {
".": {
Expand Down Expand Up @@ -79,6 +79,7 @@
"@cloudquery/cloud-ui": "^2.0.0-rc.0",
"@rudderstack/analytics-js": "^3.7.13",
"dayjs": "^1.11.13",
"decamelize": "^6.0.0",
"handlebars": "^4.7.8",
"humanize-string": "^3.0.0",
"inquirer": "^11.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const fs = require('node:fs');
const path = require('node:path');

import Handlebars from 'handlebars';
import humanizeString from 'humanize-string';
import inquirer from 'inquirer';
const Handlebars = require('handlebars');
const { default: inquirer } = require('inquirer');

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

async function main() {
const outputDir = path.join(process.cwd(), 'cloud-config-ui');
Expand Down Expand Up @@ -154,7 +150,7 @@ async function main() {
createTablesSelector,
advancedOptions,
authTokenSpecProperties,
yup: authentication === 'both' || advancedOptions.length > 0 || advancedOptions.length > 0,
yup: authentication === 'both' || authenticationToken || advancedOptions.length > 0 || advancedOptions.length > 0,
};

if (fs.existsSync(outputDir)) {
Expand Down Expand Up @@ -295,8 +291,7 @@ async function main() {
}
}

// eslint-disable-next-line unicorn/prefer-top-level-await
main();
main().catch(console.error);

function createAndCompileTemplate(templatePath, outputPath, data) {
const template = fs.readFileSync(templatePath, 'utf8');
Expand All @@ -305,3 +300,12 @@ function createAndCompileTemplate(templatePath, outputPath, data) {
fs.mkdirSync(outputDir, { recursive: true });
fs.writeFileSync(outputPath, compiledTemplate(data));
}

function humanizeString(str) {
return str
.replace(/^[\s_]+|[\s_]+$/g, '')
.replace(/[_\s]+/g, ' ')
.replace(/^[a-z]/, function(m) { return m.toUpperCase(); });
}

module.exports = main;

0 comments on commit 574e149

Please sign in to comment.