Comparing version 1.0.4 to 1.1.0
@@ -24,4 +24,4 @@ #!/usr/bin/env node | ||
.option( | ||
"-sf --serverFolder <server>", | ||
`Specify a folder on the server ${"(e.g. 358109)".meta}` | ||
"-sd --serverDir <server>", | ||
`Specify a directory on the server ${"(e.g. 358109)".meta}` | ||
) | ||
@@ -28,0 +28,0 @@ .description("Create a Github workflow with React build and FTP output") |
@@ -26,2 +26,5 @@ /* | ||
// Writing to yaml | ||
const writeYamlFile = require("write-yaml-file"); | ||
function init(options) { | ||
@@ -37,3 +40,3 @@ /* ********************************** */ | ||
`Mappe på server: ${ | ||
`umbraco/w${options.serverFolder}/www/build/`.info | ||
`umbraco/w${options.serverDir}/www/build/`.info | ||
}` | ||
@@ -44,3 +47,3 @@ ); | ||
/* ********************************** */ | ||
/* CREATE OUTPUT FOLDER */ | ||
/* CREATE OUTPUT DIR */ | ||
/* ********************************** */ | ||
@@ -90,22 +93,70 @@ const createDir = (dir) => { | ||
// Installs node_modules, caches them, builds react app & syncs to ftp folder | ||
const createYml = (server, serverFolder) => { | ||
let host = "${{ secrets.FTP_HOST_" + server + " }}"; | ||
let usr = "${{ secrets.FTP_USR_" + server + " }}"; | ||
let pwd = "${{ secrets.FTP_PWD_" + server + " }}"; | ||
execSync( | ||
"echo 'on: push\nname: 🚀 Deploy website on push\njobs:\n web-deploy:\n name: 🎉 Deploy\n runs-on: ubuntu-latest\n steps:\n - name: 🚚 Get latest code\n uses: actions/checkout@v2\n - uses: actions/setup-node@v2\n with:\n node-version: '14'\n cache: 'yarn'\n\n - name: 🧐 Check for node_modules cache\n id: cache-node-modules\n uses: actions/cache@v2\n with:\n path: node_modules\n key: node-modules-${{ hashFiles('package-lock.json') }}\n\n - name: 😅 Installing node_modules\n if: steps.cache.outputs.cache-hit != 'true'\n run: yarn install\n\n - name: 🔨 Building project!\n run: yarn build\n\n - name: 📂 Sync files through ftp\n uses: SamKirkland/FTP-Deploy-Action@4.1.0\n with:\n local-dir: ./build/\n server: " + | ||
`${host}` + | ||
"\n state-name: ../.ftp-deploy-sync-state.json\n server-dir: umbraco/w" + | ||
`${serverFolder}` + | ||
"/www/build/\n username: " + | ||
`${usr}` + | ||
"\n password: " + | ||
`${pwd}` + | ||
"'" + | ||
`>${dir}/.github/workflows/main.yml` | ||
); | ||
rl.close("success"); | ||
const createYml = (server, serverDir) => { | ||
// Set up variables to input | ||
let input_host = "${{ secrets.FTP_HOST_" + server + " }}"; | ||
let input_serverDir = `umbraco/${serverDir}/www/build/`; | ||
let input_usr = "${{ secrets.FTP_USR_" + server + " }}"; | ||
let input_pwd = "${{ secrets.FTP_PWD_" + server + " }}"; | ||
writeYamlFile(`${dir}/.github/workflows/main.yml`, { | ||
on: "push", | ||
name: "🚀 Deploy website on push", | ||
jobs: { | ||
"web-deploy": { | ||
name: "🎉 Deploy", | ||
"runs-on": "ubuntu-latest", | ||
steps: [ | ||
{ | ||
name: "🚚 Get latest code", | ||
uses: "actions/checkout@v2", | ||
}, | ||
{ | ||
uses: "actions/setup-node@v2", | ||
with: { | ||
"node-version": "14", | ||
cache: "yarn", | ||
}, | ||
}, | ||
{ | ||
name: "🧐 Check for node_modules cache", | ||
id: "cache-node-modules", | ||
uses: "actions/cache@v2", | ||
with: { | ||
path: "node_modules", | ||
key: "node-modules-${{ hashFiles('package-lock.json') }}", | ||
}, | ||
}, | ||
{ | ||
name: "😅 Installing node_modules", | ||
if: "steps.cache.outputs.cache-hit != 'true'", | ||
run: "yarn install", | ||
}, | ||
{ | ||
name: "🔨 Building project!", | ||
run: "yarn build", | ||
}, | ||
{ | ||
name: "📂 Sync files through ftp", | ||
uses: "SamKirkland/FTP-Deploy-Action@4.1.0", | ||
with: { | ||
"local-dir": "./build/", | ||
server: input_host, | ||
"server-dir": input_serverDir, | ||
username: input_usr, | ||
password: input_pwd, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}) | ||
.then(() => { | ||
rl.close("success"); | ||
}) | ||
.catch(() => { | ||
rl.close("failure"); | ||
}); | ||
}; | ||
if (options.server && options.serverFolder) { | ||
createYml(options.server, options.serverFolder); | ||
if (options.server && options.serverDir) { | ||
createYml(options.server, options.serverDir); | ||
} else { | ||
@@ -124,3 +175,3 @@ /* ********************************** */ | ||
/* ********************************** */ | ||
/* SERVER FOLDER */ | ||
/* SERVER DIR */ | ||
/* ********************************** */ | ||
@@ -133,4 +184,4 @@ rl.question( | ||
} `, | ||
function (serverFolder) { | ||
createYml(options.server, serverFolder); | ||
function (serverDir) { | ||
createYml(options.server, serverDir); | ||
} | ||
@@ -144,7 +195,7 @@ ); | ||
) { | ||
if (options.serverFolder) { | ||
createYml(server, serverFolder); | ||
if (options.serverDir) { | ||
createYml(server, serverDir); | ||
} else { | ||
/* ********************************** */ | ||
/* SERVER FOLDER */ | ||
/* SERVER DIR */ | ||
/* ********************************** */ | ||
@@ -157,4 +208,4 @@ rl.question( | ||
} `, | ||
function (serverFolder) { | ||
createYml(server, serverFolder); | ||
function (serverDir) { | ||
createYml(server, serverDir); | ||
} | ||
@@ -161,0 +212,0 @@ ); |
{ | ||
"name": "07-cli", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -18,6 +18,8 @@ "main": "index.js", | ||
"conf": "^10.0.3", | ||
"js-yaml": "^4.1.0", | ||
"node-color-readline": "^1.0.1", | ||
"node-emoji": "^1.11.0", | ||
"tls-test": "https://tls-test.npmjs.com/tls-test-1.0.0.tgz" | ||
"tls-test": "https://tls-test.npmjs.com/tls-test-1.0.0.tgz", | ||
"write-yaml-file": "^4.2.0" | ||
} | ||
} |
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
54447
300
9
8
+ Addedjs-yaml@^4.1.0
+ Addedwrite-yaml-file@^4.2.0
+ Addedargparse@2.0.1(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)
+ Addedwrite-file-atomic@3.0.3(transitive)
+ Addedwrite-yaml-file@4.2.0(transitive)