Comparing version 1.0.1 to 1.0.2
@@ -0,6 +1,16 @@ | ||
/* | ||
Code to create .github/workflows/main.yml file | ||
Used for building Create React Apps from Git and syncing to FTP server | ||
All server info is specified in Github secrets | ||
*/ | ||
// Dependency to execute code in terminal | ||
const execSync = require("child_process").execSync; | ||
const commander = require("commander"); | ||
const { program } = require("commander"); | ||
// File system, dependency to check paths | ||
const fs = require("fs"); | ||
const { resolve } = require("path"); | ||
// Question dependencies | ||
const readline = require("readline"); | ||
@@ -11,3 +21,4 @@ const rl = readline.createInterface({ | ||
}); | ||
const emoji = require("node-emoji"); | ||
// Colors to style console logs | ||
const colors = require("colors"); | ||
@@ -22,4 +33,10 @@ colors.setTheme({ | ||
}); | ||
// Emoji function | ||
const emoji = require("node-emoji"); | ||
const e = (n) => emoji.get(n); | ||
function init(options) { | ||
/* ********************************** */ | ||
/* LOG ARGUMENTS */ | ||
/* ********************************** */ | ||
Object.values(options).length > 0 && console.log("#".meta); | ||
@@ -36,3 +53,48 @@ options.output && console.log(`Prosjektnavn: ${options.output.info}`); | ||
/* ********************************** */ | ||
/* CREATE OUTPUT FOLDER */ | ||
/* ********************************** */ | ||
const createDir = (dir) => { | ||
if (dir) { | ||
let exists = fs.existsSync(dir.replace(/'/g, "")); | ||
if (exists) { | ||
console.log( | ||
`${e("nerd_face")} ${"Mappen eksisterer!".green} ${ | ||
`${resolve(dir)}`.meta | ||
}` | ||
); | ||
console.log( | ||
`${e("nerd_face")} ${ | ||
"Github workflow - Lager mappestruktur".green | ||
} ${"(.github/workflows/)".meta}` | ||
); | ||
execSync(`mkdir -p ${dir}/.github/workflows`); | ||
initYml(dir); | ||
} else if (!exists) { | ||
console.log( | ||
`${e("worried")} ${ | ||
"Mappen eksisterer ikke".red | ||
} Oppretter mappe.${`${resolve(dir)}`.meta}` | ||
); | ||
execSync(`mkdir -p ${dir}/.github/workflows`); | ||
console.log( | ||
`${e("nerd_face")} ${ | ||
"Github workflow - Lager mappestruktur".green | ||
} ${"(.github/workflows/)".meta}` | ||
); | ||
initYml(dir); | ||
} | ||
} else { | ||
rl.close(); | ||
} | ||
}; | ||
/* ********************************** */ | ||
/* CREATE YML FILE */ | ||
/* ********************************** */ | ||
const initYml = (dir) => { | ||
/* ********************************** */ | ||
/* CREATE GITHUB WORKFLOW YML */ | ||
/* ********************************** */ | ||
// Installs node_modules, caches them, builds react app & syncs to ftp folder | ||
const createYml = (server, serverFolder) => { | ||
@@ -59,2 +121,5 @@ let host = "${{ secrets.FTP_HOST_" + server + " }}"; | ||
} else { | ||
/* ********************************** */ | ||
/* SERVER */ | ||
/* ********************************** */ | ||
rl.question( | ||
@@ -76,2 +141,5 @@ `${e( | ||
} else { | ||
/* ********************************** */ | ||
/* SERVER FOLDER */ | ||
/* ********************************** */ | ||
rl.question( | ||
@@ -96,36 +164,3 @@ `${e( | ||
const createDir = (dir) => { | ||
if (dir) { | ||
let exists = fs.existsSync(dir.replace(/'/g, "")); | ||
if (exists) { | ||
console.log( | ||
`${e("nerd_face")} ${"Mappen eksisterer!".green} ${ | ||
`${resolve(dir)}`.meta | ||
}` | ||
); | ||
console.log( | ||
`${e("nerd_face")} ${ | ||
"Github workflow - Lager mappestruktur".green | ||
} ${"(.github/workflows/)".meta}` | ||
); | ||
execSync(`mkdir -p ${dir}/.github/workflows`); | ||
initYml(dir); | ||
} else if (!exists) { | ||
console.log( | ||
`${e("worried")} ${ | ||
"Mappen eksisterer ikke".red | ||
} Oppretter mappe.${`${resolve(dir)}`.meta}` | ||
); | ||
execSync(`mkdir -p ${dir}/.github/workflows`); | ||
console.log( | ||
`${e("nerd_face")} ${ | ||
"Github workflow - Lager mappestruktur".green | ||
} ${"(.github/workflows/)".meta}` | ||
); | ||
initYml(dir); | ||
} | ||
} else { | ||
rl.close(); | ||
} | ||
}; | ||
// Check for arguments or ask for info | ||
if (options.output) { | ||
@@ -142,2 +177,3 @@ createDir(options.output); | ||
// Conclusion | ||
rl.on("close", function (status) { | ||
@@ -144,0 +180,0 @@ if (status === "success") { |
{ | ||
"name": "07-cli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
52463
248
6