Skip to content

Commit

Permalink
File path changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kreloaded committed Oct 3, 2022
1 parent ea8afa7 commit c069ad1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "plg-ghost",
"version": "1.0.0",
"description": "Host Ghost server in AWS ECS and provision to host static files on AWS S3",
"main": "./dist/run.js",
"main": "./dist/src/run.js",
"scripts": {
"dev": "ts-node ./src/run.ts",
"build": "tsc",
Expand Down Expand Up @@ -43,12 +43,12 @@
"@cdktf/provider-aws": "8.0.12",
"cdktf": "0.11.2",
"cdktf-cli": "0.11.2",
"chalk": "4.1.2",
"commander": "9.3.0",
"constructs": "10.1.37",
"psl": "1.9.0",
"readline-sync": "1.4.10",
"shelljs": "0.8.5",
"chalk": "4.1.2"
"shelljs": "0.8.5"
},
"devDependencies": {
"@types/jest": "28.1.1",
Expand Down
5 changes: 3 additions & 2 deletions src/lib/getInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs';
import * as readlineSyc from 'readline-sync';
import chalk from 'chalk';
import { Command, Argument } from 'commander';
import { getRootDomainFromUrl, readJsonFileWithFileName, getCurrentTimestampInSeconds } from '../lib/util';
import { getRootDomainFromUrl, readJsonFile, getCurrentTimestampInSeconds } from '../lib/util';

import commonConfig from '../config/common.json';

Expand Down Expand Up @@ -120,7 +120,8 @@ class GetInput {
* @returns {boolean}
*/
_hasPreviousConfigInFile(): boolean {
const configData = readJsonFileWithFileName(commonConfig.configFile);
const filePath = `${__dirname}/${commonConfig.configFile}`;
const configData = readJsonFile(filePath);

let pass = true;
for (const key in USER_CONFIGS) {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ export function getPathSuffixFromUrl(url: string): string {
return urlParts.slice(1).join('/');
}

export function readJsonFileWithFileName(fileName: string): any {
export function readJsonFile(filePath: string): any {
let fileContent = null;
try {
const data = fs.readFileSync(fileName, 'utf-8');
const data = fs.readFileSync(filePath, 'utf-8');
fileContent = JSON.parse(data);
} catch (err) {
console.log(err);
// console.log(err);
} finally {
fileContent = fileContent || {};
}
Expand Down
5 changes: 3 additions & 2 deletions src/terraform/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { App } from 'cdktf';
import { BackendStack } from './backend';
import { GhostStack } from './ghost';
import { readJsonFileWithFileName } from '../lib/util';
import { readJsonFile } from '../lib/util';

import commonConfig from '../config/common.json';

const app = new App();

const userInput = readJsonFileWithFileName(commonConfig.configFile);
const filePath = `${__dirname}/${commonConfig.configFile}`;
const userInput = readJsonFile(filePath);

new BackendStack(app, commonConfig.backendStackName, {
accessKey: userInput.aws.accessKeyId,
Expand Down

0 comments on commit c069ad1

Please sign in to comment.