diff --git a/package-lock.json b/package-lock.json index 842c6d0..2432fd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cloudcannon/command-builder", - "version": "1.1.3", + "version": "1.1.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@cloudcannon/command-builder", - "version": "1.1.3", + "version": "1.1.6", "license": "ISC", "devDependencies": { "eslint": "^7.27.0", diff --git a/package.json b/package.json index 1c6c3ba..d2abe2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cloudcannon/command-builder", - "version": "1.1.5", + "version": "1.1.6", "description": "A script that builds the script that builds your site", "main": "src/index.js", "scripts": { diff --git a/src/index.js b/src/index.js index 04357a6..a29571a 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,7 @@ const Static = require('./lib/static'); const Parser = require('./helpers/parser'); const BuildOptions = require('./options/ssg-options'); +const VersionOptions = require('./options/version-options'); module.exports = { Astro: ReaderNpm, @@ -30,5 +31,6 @@ module.exports = { SvelteKit: ReaderNpm, Parser, - BuildOptions + BuildOptions, + VersionOptions }; diff --git a/src/lib/compiler.js b/src/lib/compiler.js index 8bf6901..69c951c 100644 --- a/src/lib/compiler.js +++ b/src/lib/compiler.js @@ -1,3 +1,5 @@ +const versionOptions = require('../options/version-options'); + module.exports = class Compiler { static hookCommands(path) { return [ @@ -8,8 +10,53 @@ module.exports = class Compiler { ]; } - static getPreinstallCommands() { - return Compiler.hookCommands('.cloudcannon/preinstall'); + static getVersionCommands(buildConfig) { + return Object.entries(versionOptions).flatMap(([name, options]) => { + if (buildConfig[name] && buildConfig[name] !== options.default) { + const command = options.getVersionCommand(buildConfig[name]); + if (!command) { + return []; + } + + return [ + `echo "$ ${command}"`, + command + ]; + } + + return []; + }); + } + + static getCheckCommands() { + const result = Object.entries(versionOptions).flatMap(([name, options]) => { + const shortName = name.slice(0, -7); + return [ + `DETECTED_${shortName}_VERSION=${options.checkCommand}`, + `echo "[🏷${shortName}:\${DETECTED_${shortName}_VERSION}]"` + ]; + }); + + result.push( + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \"s/[][]//g\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + 'DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^Bundler version //g")', + + /* eslint-disable no-template-curly-in-string */ + 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', + 'echo "[🏷yarn:${DETECTED_YARN_VERSION}]"', + 'echo "[🏷bundler:${DETECTED_BUNDLE_VERSION}]"' + /* eslint-enable no-template-curly-in-string */ + ); + + return result; + } + + static getPreinstallCommands(buildConfig = {}) { + return [ + ...Compiler.getVersionCommands(buildConfig), + ...Compiler.hookCommands('.cloudcannon/preinstall') + ]; } static getPrebuildCommands() { diff --git a/src/lib/eleventy.js b/src/lib/eleventy.js index 5191ce6..7a459fa 100644 --- a/src/lib/eleventy.js +++ b/src/lib/eleventy.js @@ -2,18 +2,6 @@ const Compiler = require('./compiler'); const { parseOptions } = require('../helpers/parser'); const { addEchoCommand } = require('../helpers/commands'); -function getCheckCommands() { - return [ - 'DETECTED_NPM_VERSION=$(npm -v | sed \'s/[][]//g\')', - 'DETECTED_NODE_VERSION=$(node -v | sed \'s/[][]//g\' | sed \'s/^v//\')', - - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"' - ]; -} - function getVersioningCommands() { return [ 'export CC_ELEVENTY_VERSION=`npm list @11ty/eleventy | grep @11ty/eleventy | awk -F "@" \'{print $NF}\'`', @@ -111,10 +99,10 @@ module.exports = class Eleventy { const outputPath = buildConfig.output.replace(/^\//, ''); return [ - ...Compiler.getPreinstallCommands(), + ...Compiler.getPreinstallCommands(buildConfig), ...getInstallCommands(buildConfig), ...Compiler.getPrebuildCommands(), - ...getCheckCommands(), + ...Compiler.getCheckCommands(), ...getBuildCommands(buildConfig).reduce(addEchoCommand, []), ...Compiler.getPostbuildCommands(), ...Compiler.getOutputCommands(outputPath, buildConfig.preserveOutput), diff --git a/src/lib/hugo.js b/src/lib/hugo.js index d14689f..2b1eb89 100644 --- a/src/lib/hugo.js +++ b/src/lib/hugo.js @@ -3,17 +3,15 @@ const Compiler = require('./compiler'); const Parser = require('../helpers/parser'); const { addEchoCommand } = require('../helpers/commands'); -function getCheckCommands() { - return [ - "DETECTED_HUGO_VERSION=$(hugo version | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1)", - - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷hugo:${DETECTED_HUGO_VERSION}]"' - ]; -} - function getBuildCommands(buildConfig) { - const tag = buildConfig.use_beta_plugin ? '@next' : ''; + let pluginTag; + if (buildConfig.manage_plugin_manually) { + pluginTag = ''; + } else if (buildConfig.use_beta_plugin) { + pluginTag = '@next'; + } else { + pluginTag = '@latest'; + } const buildOptions = Parser.parseOptions('hugo', buildConfig); return [ @@ -21,8 +19,8 @@ function getBuildCommands(buildConfig) { `hugo ${buildOptions}`, '__CURRENT_NVM_VERSION=$(nvm current)', 'nvm use default > /dev/null', - `echo '$ npx cloudcannon-hugo${tag} ${buildOptions}'`, - `npx cloudcannon-hugo${tag} ${buildOptions}`, + `echo '$ npx cloudcannon-hugo${pluginTag} ${buildOptions}'`, + `npx cloudcannon-hugo${pluginTag} ${buildOptions}`, 'nvm use "$__CURRENT_NVM_VERSION" > /dev/null', 'unset __CURRENT_NVM_VERSION' ]; @@ -47,11 +45,11 @@ module.exports = class Hugo { ).replace(/^\//, ''); return [ - ...Compiler.getPreinstallCommands(), + ...Compiler.getPreinstallCommands(buildConfig), ...getInstallCommands(buildConfig).reduce(addEchoCommand, []), ...Compiler.getLegacyPrebuildCommands(), ...Compiler.getPrebuildCommands(), - ...getCheckCommands(), + ...Compiler.getCheckCommands(), ...getBuildCommands(buildConfig), ...Compiler.getPostbuildCommands(), ...Compiler.getOutputCommands(outputPath, buildConfig.preserveOutput), diff --git a/src/lib/jekyll.js b/src/lib/jekyll.js index abc358c..2a274e2 100644 --- a/src/lib/jekyll.js +++ b/src/lib/jekyll.js @@ -36,19 +36,6 @@ module.exports = class Jekyll { `echo "$ export JEKYLL_ENV=\\"${environment}\\""`, `export JEKYLL_ENV="${environment}"`, - 'if [ -f ".ruby-version" ]; then', - ' echo "$ ruby -v (Using .ruby-version)"', - ' ruby -v || (echo "\\nPlease use one of the following versions:\\n" && rbenv versions 2> /dev/null && false)', - 'fi', - - 'DETECTED_BUNDLE_VERSION=$(bundle -v | sed \'s/[][]//g\' | sed \'s/^Bundler version //g\')', - 'DETECTED_RUBY_VERSION=$(ruby -v | sed \'s/[][]//g\' | sed \'s/^ruby //g\' | cut -d \' \' -f 1)', - - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷bundler:${DETECTED_BUNDLE_VERSION}]"', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷ruby:${DETECTED_RUBY_VERSION}]"', - `if [ -d "${options.bundleFolderPath}" ]; then`, ` echo "$ rm -rf ${options.bundleFolderPath}"`, ` rm -rf ${options.bundleFolderPath}`, @@ -63,7 +50,7 @@ module.exports = class Jekyll { ' USE_BUNDLE=true', 'fi', - ...Compiler.getPreinstallCommands(), + ...Compiler.getPreinstallCommands(buildConfig), 'if [ "$USE_BUNDLE" = true ]; then', ' echo "$ bundle version"', @@ -84,6 +71,7 @@ module.exports = class Jekyll { 'else', ...Compiler.getLegacyPrebuildCommands(), ...Compiler.getPrebuildCommands(), + ...Compiler.getCheckCommands(), ` echo "$ jekyll build ${buildOptions}";`, ` jekyll build ${buildOptions}`, 'fi', diff --git a/src/lib/reader.js b/src/lib/reader.js index 9f6c9ee..6d96896 100644 --- a/src/lib/reader.js +++ b/src/lib/reader.js @@ -2,26 +2,6 @@ const { join } = require('path'); const Compiler = require('./compiler'); const { addEchoCommand } = require('../helpers/commands'); -function getCheckCommands() { - return [ - "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \"s/[][]//g\")", - 'DETECTED_NODE_VERSION=$((node -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^v//")', - 'DETECTED_DENO_VERSION=$((deno -V 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^deno //")', - "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", - 'DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^Bundler version //g")', - 'DETECTED_RUBY_VERSION=$((ruby -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^ruby //g" | cut -d " " -f 1)', - - /* eslint-disable no-template-curly-in-string */ - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"', - 'echo "[🏷deno:${DETECTED_DENO_VERSION}]"', - 'echo "[🏷yarn:${DETECTED_YARN_VERSION}]"', - 'echo "[🏷ruby-bundler:${DETECTED_BUNDLE_VERSION}]"', - 'echo "[🏷ruby:${DETECTED_RUBY_VERSION}]"' - /* eslint-enable no-template-curly-in-string */ - ]; -} - function getInstallCommands(buildConfig) { return buildConfig.install_command ? [buildConfig.install_command, `cd ${Compiler.getInputPath()}`] @@ -29,7 +9,14 @@ function getInstallCommands(buildConfig) { } function getBuildCommands(buildConfig, buildOutputPath) { - const pluginTag = buildConfig.use_beta_plugin ? '@next' : ''; + let pluginTag; + if (buildConfig.manage_plugin_manually) { + pluginTag = ''; + } else if (buildConfig.use_beta_plugin) { + pluginTag = '@next'; + } else { + pluginTag = '@latest'; + } return [ ...(buildConfig.build_command @@ -54,10 +41,10 @@ module.exports = class Reader { const buildOutputPath = join('.', buildConfig.output_path || 'public'); return [ - ...Compiler.getPreinstallCommands(), + ...Compiler.getPreinstallCommands(buildConfig), ...getInstallCommands(buildConfig).reduce(addEchoCommand, []), ...Compiler.getPrebuildCommands(), - ...getCheckCommands(), + ...Compiler.getCheckCommands(), ...getBuildCommands(buildConfig, buildOutputPath), ...Compiler.getPostbuildCommands(), ...Compiler.getOutputCommands( diff --git a/src/lib/static.js b/src/lib/static.js index 37cc823..2968feb 100644 --- a/src/lib/static.js +++ b/src/lib/static.js @@ -1,17 +1,12 @@ -const { join } = require('path'); -const Compiler = require('./compiler'); +const Reader = require('./reader'); module.exports = class Static { - static runScriptCommands(buildConfig) { - const outputPath = join(Compiler.getInputPath(), buildConfig.source || ''); - - return [ - ...Compiler.getPreinstallCommands(), - ...Compiler.getLegacyPrebuildCommands(), - ...Compiler.getPrebuildCommands(), - ...Compiler.getOutputCommands(outputPath, buildConfig.preserveOutput), - ...Compiler.getPostbuildCommands(), - ...Compiler.getExportCommands() - ]; + static runScriptCommands(buildConfig = {}) { + return Reader.runScriptCommands({ + ...buildConfig, + output_path: buildConfig.source || '', + install_command: '', + build_command: '' + }); } }; diff --git a/src/options/version-options.js b/src/options/version-options.js new file mode 100644 index 0000000..0b70c2e --- /dev/null +++ b/src/options/version-options.js @@ -0,0 +1,97 @@ +const versionOptions = { + hugoVersion: { + name: 'Hugo version', + type: 'string', + default: '0.122.0', + checkCommand: + "$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + getVersionCommand: (version) => `install-hugo ${version}` + }, + rubyVersion: { + name: 'Ruby version', + type: 'select', + default: '2.7.3', + checkCommand: + '$((ruby -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^ruby //g" | cut -d " " -f 1 | cut -d "p" -f 1)', + getVersionCommand: (version) => (version !== 'file' ? `rbenv local ${version}` : null), + options: [ + { + value: '2.6.7' + }, + { + value: '2.7.3' + }, + { + value: '3.0.1' + }, + { + value: '3.1.3' + }, + { + value: '3.2.0' + }, + { + name: 'Use my .ruby-version file', + value: 'file' + } + ] + }, + nodeVersion: { + name: 'Node version', + type: 'select', + default: '18', + checkCommand: + '$((node -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^v//")', + getVersionCommand: (version) => (version !== 'file' + ? `nvm use ${version}` + : '[ -f .nvmrc ] && nvm install'), + options: [ + { + value: '10' + }, + { + value: '12' + }, + { + value: '14' + }, + { + value: '15' + }, + { + value: '16' + }, + { + value: '18' + }, + { + value: '20' + }, + { + name: 'Use my .nvmrc file', + value: 'file' + } + ] + }, + denoVersion: { + name: 'Deno version', + type: 'select', + default: '1.40.2', + checkCommand: + '$((deno -V 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^deno //")', + getVersionCommand: (version) => (version !== 'file' + ? `dvm use ${version}` + : '[ -f .dvmrc ] && dvm install'), + options: [ + { + value: '1.40.2' + }, + { + name: 'Use my .dvmrc file', + value: 'file' + } + ] + } +}; + +module.exports = versionOptions; diff --git a/tests/__snapshots__/eleventy.test.js.snap b/tests/__snapshots__/eleventy.test.js.snap new file mode 100644 index 0000000..11b6866 --- /dev/null +++ b/tests/__snapshots__/eleventy.test.js.snap @@ -0,0 +1,216 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`outputs with @next config 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo '$ npm pkg set dependencies.eleventy-plugin-cloudcannon=next || npm install eleventy-plugin-cloudcannon@next'", + "npm pkg set dependencies.eleventy-plugin-cloudcannon=next || npm install eleventy-plugin-cloudcannon@next", + "echo '$ npm install'", + "npm install", + "export CC_ELEVENTY_VERSION=\`npm list @11ty/eleventy | grep @11ty/eleventy | awk -F \\"@\\" '{print $NF}'\`", + "if [[ -z \\"$CC_ELEVENTY_VERSION\\" ]]; then export CC_ELEVENTY_VERSION=unknown; fi", + "echo \\"[🏷@11ty/eleventy:\${CC_ELEVENTY_VERSION}]\\"", + "echo '$ if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi'", + "if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi", + "echo '$ if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi'", + "if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi", + "echo '$ if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi'", + "if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi", + "echo '$ if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi'", + "if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi", + "echo '$ echo $CONFIG'", + "echo $CONFIG", + "echo '$ CONFIG_DIR=\`dirname $CONFIG\`'", + "CONFIG_DIR=\`dirname $CONFIG\`", + "echo '$ echo $CONFIG_DIR'", + "echo $CONFIG_DIR", + "echo '$ PWD=\`pwd\`'", + "PWD=\`pwd\`", + "echo '$ echo $PWD'", + "echo $PWD", + "echo '$ CONFIG_BASE=\`basename $CONFIG\`'", + "CONFIG_BASE=\`basename $CONFIG\`", + "echo '$ echo $CONFIG_BASE'", + "echo $CONFIG_BASE", + "echo '$ CONFIG_INJECTED=\\"$PWD/$CONFIG_DIR/inject-cloudcannon.config.cjs\\"'", + "CONFIG_INJECTED=\\"$PWD/$CONFIG_DIR/inject-cloudcannon.config.cjs\\"", + "echo '$ echo $CONFIG_INJECTED'", + "echo $CONFIG_INJECTED", + "echo '$ export CC_ELEVENTY_CONFIG=\\"$PWD/$CONFIG_DIR/default-$CONFIG_BASE\\"'", + "export CC_ELEVENTY_CONFIG=\\"$PWD/$CONFIG_DIR/default-$CONFIG_BASE\\"", + "echo '$ echo $CC_ELEVENTY_CONFIG'", + "echo $CC_ELEVENTY_CONFIG", + "echo '$ if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi'", + "if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi", + "echo '$ cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED'", + "cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED", + "echo '$ export CC_ELEVENTY_INPUT=\\"src\\"'", + "export CC_ELEVENTY_INPUT=\\"src\\"", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "echo '$ npx @11ty/eleventy --config=$CONFIG_INJECTED --input src --incremental --ignore-initial --output _site'", + "npx @11ty/eleventy --config=$CONFIG_INJECTED --input src --incremental --ignore-initial --output _site", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"_site\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"_site\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; + +exports[`outputs with empty config 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo '$ npm pkg set dependencies.eleventy-plugin-cloudcannon=latest || npm install eleventy-plugin-cloudcannon@latest'", + "npm pkg set dependencies.eleventy-plugin-cloudcannon=latest || npm install eleventy-plugin-cloudcannon@latest", + "echo '$ npm install'", + "npm install", + "export CC_ELEVENTY_VERSION=\`npm list @11ty/eleventy | grep @11ty/eleventy | awk -F \\"@\\" '{print $NF}'\`", + "if [[ -z \\"$CC_ELEVENTY_VERSION\\" ]]; then export CC_ELEVENTY_VERSION=unknown; fi", + "echo \\"[🏷@11ty/eleventy:\${CC_ELEVENTY_VERSION}]\\"", + "echo '$ if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi'", + "if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi", + "echo '$ if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi'", + "if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi", + "echo '$ if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi'", + "if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi", + "echo '$ if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi'", + "if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi", + "echo '$ echo $CONFIG'", + "echo $CONFIG", + "echo '$ CONFIG_DIR=\`dirname $CONFIG\`'", + "CONFIG_DIR=\`dirname $CONFIG\`", + "echo '$ echo $CONFIG_DIR'", + "echo $CONFIG_DIR", + "echo '$ PWD=\`pwd\`'", + "PWD=\`pwd\`", + "echo '$ echo $PWD'", + "echo $PWD", + "echo '$ CONFIG_BASE=\`basename $CONFIG\`'", + "CONFIG_BASE=\`basename $CONFIG\`", + "echo '$ echo $CONFIG_BASE'", + "echo $CONFIG_BASE", + "echo '$ CONFIG_INJECTED=\\"$PWD/$CONFIG_DIR/inject-cloudcannon.config.cjs\\"'", + "CONFIG_INJECTED=\\"$PWD/$CONFIG_DIR/inject-cloudcannon.config.cjs\\"", + "echo '$ echo $CONFIG_INJECTED'", + "echo $CONFIG_INJECTED", + "echo '$ export CC_ELEVENTY_CONFIG=\\"$PWD/$CONFIG_DIR/default-$CONFIG_BASE\\"'", + "export CC_ELEVENTY_CONFIG=\\"$PWD/$CONFIG_DIR/default-$CONFIG_BASE\\"", + "echo '$ echo $CC_ELEVENTY_CONFIG'", + "echo $CC_ELEVENTY_CONFIG", + "echo '$ if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi'", + "if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi", + "echo '$ cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED'", + "cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "echo '$ npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site'", + "npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"_site\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"_site\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; + +exports[`outputs with mange_plugin_manually 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo '$ npm install'", + "npm install", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "echo '$ npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site'", + "npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"_site\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"_site\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; diff --git a/tests/__snapshots__/hugo.test.js.snap b/tests/__snapshots__/hugo.test.js.snap new file mode 100644 index 0000000..8229819 --- /dev/null +++ b/tests/__snapshots__/hugo.test.js.snap @@ -0,0 +1,121 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`outputs with empty config 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo '$ export NODE_PATH=\`pwd\`/node_modules:$NODE_PATH'", + "export NODE_PATH=\`pwd\`/node_modules:$NODE_PATH", + "echo '$ [ -f package.json ] && npm i'", + "[ -f package.json ] && npm i", + "echo '$ cd /usr/local/__site/src/'", + "cd /usr/local/__site/src/", + "if [ -f \\"_cloudcannon-prebuild.sh\\" ]; then", + " echo \\"$ bash _cloudcannon-prebuild.sh\\"", + " echo \\"DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild\\"", + " bash -l _cloudcannon-prebuild.sh", + "fi", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "echo '$ hugo --destination public'", + "hugo --destination public", + "__CURRENT_NVM_VERSION=$(nvm current)", + "nvm use default > /dev/null", + "echo '$ npx cloudcannon-hugo@latest --destination public'", + "npx cloudcannon-hugo@latest --destination public", + "nvm use \\"$__CURRENT_NVM_VERSION\\" > /dev/null", + "unset __CURRENT_NVM_VERSION", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"public\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"public\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; + +exports[`outputs with source directory configured 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo '$ export NODE_PATH=\`pwd\`/node_modules:$NODE_PATH'", + "export NODE_PATH=\`pwd\`/node_modules:$NODE_PATH", + "echo '$ [ -f package.json ] && npm i'", + "[ -f package.json ] && npm i", + "echo '$ cd /usr/local/__site/src/'", + "cd /usr/local/__site/src/", + "if [ -f \\"_cloudcannon-prebuild.sh\\" ]; then", + " echo \\"$ bash _cloudcannon-prebuild.sh\\"", + " echo \\"DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild\\"", + " bash -l _cloudcannon-prebuild.sh", + "fi", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "echo '$ hugo --source src --destination public'", + "hugo --source src --destination public", + "__CURRENT_NVM_VERSION=$(nvm current)", + "nvm use default > /dev/null", + "echo '$ npx cloudcannon-hugo@latest --source src --destination public'", + "npx cloudcannon-hugo@latest --source src --destination public", + "nvm use \\"$__CURRENT_NVM_VERSION\\" > /dev/null", + "unset __CURRENT_NVM_VERSION", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"src/public\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"src/public\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; diff --git a/tests/__snapshots__/jekyll.test.js.snap b/tests/__snapshots__/jekyll.test.js.snap new file mode 100644 index 0000000..0409f69 --- /dev/null +++ b/tests/__snapshots__/jekyll.test.js.snap @@ -0,0 +1,271 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`outputs with empty config 1`] = ` +Array [ + "echo \\"$ export JEKYLL_ENV=\\\\\\"production\\\\\\"\\"", + "export JEKYLL_ENV=\\"production\\"", + "if [ -d \\"undefined\\" ]; then", + " echo \\"$ rm -rf undefined\\"", + " rm -rf undefined", + "fi", + "USE_BUNDLE=false", + "if [ -f /usr/local/__site/src/\\"$BUNDLE_GEMFILE\\" ]; then", + " echo \\"$ export BUNDLE_GEMFILE=/usr/local/__site/src/$BUNDLE_GEMFILE\\"", + " export BUNDLE_GEMFILE=/usr/local/__site/src/\\"$BUNDLE_GEMFILE\\"", + " USE_BUNDLE=true", + "elif [ -f /usr/local/__site/src/Gemfile ]; then", + " USE_BUNDLE=true", + "fi", + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "if [ \\"$USE_BUNDLE\\" = true ]; then", + " echo \\"$ bundle version\\"", + " bundle version", + " echo \\"$ bundle config --global jobs 4\\"", + " bundle config --global jobs 4 && echo \\"Configured concurrent installs!\\"", + " echo \\"$ bundle config build.nokogiri --use-system-libraries\\"", + " bundle config build.nokogiri --use-system-libraries && echo \\"Configured nokogiri flag!\\"", + " echo \\"$ bundle install\\"", + " bundle install", + "if [ -f \\"_cloudcannon-prebuild.sh\\" ]; then", + " echo \\"$ bash _cloudcannon-prebuild.sh\\"", + " echo \\"DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild\\"", + " bash -l _cloudcannon-prebuild.sh", + "fi", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + " echo \\"$ bundle exec jekyll build \\"", + " bundle exec jekyll build ", + "else", + "if [ -f \\"_cloudcannon-prebuild.sh\\" ]; then", + " echo \\"$ bash _cloudcannon-prebuild.sh\\"", + " echo \\"DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild\\"", + " bash -l _cloudcannon-prebuild.sh", + "fi", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + " echo \\"$ jekyll build \\";", + " jekyll build ", + "fi", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"_site\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"_site\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; + +exports[`outputs with enable_bundle_cache or use_local_bundle 1`] = ` +Array [ + "echo \\"$ export JEKYLL_ENV=\\\\\\"production\\\\\\"\\"", + "export JEKYLL_ENV=\\"production\\"", + "if [ -d \\"undefined\\" ]; then", + " echo \\"$ rm -rf undefined\\"", + " rm -rf undefined", + "fi", + "USE_BUNDLE=false", + "if [ -f /usr/local/__site/src/\\"$BUNDLE_GEMFILE\\" ]; then", + " echo \\"$ export BUNDLE_GEMFILE=/usr/local/__site/src/$BUNDLE_GEMFILE\\"", + " export BUNDLE_GEMFILE=/usr/local/__site/src/\\"$BUNDLE_GEMFILE\\"", + " USE_BUNDLE=true", + "elif [ -f /usr/local/__site/src/Gemfile ]; then", + " USE_BUNDLE=true", + "fi", + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "if [ \\"$USE_BUNDLE\\" = true ]; then", + " echo \\"$ bundle version\\"", + " bundle version", + " echo \\"$ bundle config --global jobs 4\\"", + " bundle config --global jobs 4 && echo \\"Configured concurrent installs!\\"", + " echo \\"$ bundle config build.nokogiri --use-system-libraries\\"", + " bundle config build.nokogiri --use-system-libraries && echo \\"Configured nokogiri flag!\\"", + " if [[ $DETECTED_BUNDLE_VERSION == \\"1.\\"* ]]; then", + " echo \\"$ bundle install --path /usr/local/__bundle\\"", + " bundle install --path /usr/local/__bundle", + " else", + " echo \\"$ bundle config set path /usr/local/__bundle\\"", + " bundle config set path /usr/local/__bundle", + " echo \\"$ bundle install\\"", + " bundle install", + " fi", + " echo \\"$ bundle clean\\"", + " bundle clean && echo \\"All clean!\\"", + "if [ -f \\"_cloudcannon-prebuild.sh\\" ]; then", + " echo \\"$ bash _cloudcannon-prebuild.sh\\"", + " echo \\"DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild\\"", + " bash -l _cloudcannon-prebuild.sh", + "fi", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + " echo \\"$ bundle exec jekyll build \\"", + " bundle exec jekyll build ", + "else", + "if [ -f \\"_cloudcannon-prebuild.sh\\" ]; then", + " echo \\"$ bash _cloudcannon-prebuild.sh\\"", + " echo \\"DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild\\"", + " bash -l _cloudcannon-prebuild.sh", + "fi", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + " echo \\"$ jekyll build \\";", + " jekyll build ", + "fi", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"_site\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"_site\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; + +exports[`outputs with enable_bundle_cache or use_local_bundle 2`] = ` +Array [ + "echo \\"$ export JEKYLL_ENV=\\\\\\"production\\\\\\"\\"", + "export JEKYLL_ENV=\\"production\\"", + "if [ -d \\"undefined\\" ]; then", + " echo \\"$ rm -rf undefined\\"", + " rm -rf undefined", + "fi", + "USE_BUNDLE=false", + "if [ -f /usr/local/__site/src/\\"$BUNDLE_GEMFILE\\" ]; then", + " echo \\"$ export BUNDLE_GEMFILE=/usr/local/__site/src/$BUNDLE_GEMFILE\\"", + " export BUNDLE_GEMFILE=/usr/local/__site/src/\\"$BUNDLE_GEMFILE\\"", + " USE_BUNDLE=true", + "elif [ -f /usr/local/__site/src/Gemfile ]; then", + " USE_BUNDLE=true", + "fi", + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "if [ \\"$USE_BUNDLE\\" = true ]; then", + " echo \\"$ bundle version\\"", + " bundle version", + " echo \\"$ bundle config --global jobs 4\\"", + " bundle config --global jobs 4 && echo \\"Configured concurrent installs!\\"", + " echo \\"$ bundle config build.nokogiri --use-system-libraries\\"", + " bundle config build.nokogiri --use-system-libraries && echo \\"Configured nokogiri flag!\\"", + " if [[ $DETECTED_BUNDLE_VERSION == \\"1.\\"* ]]; then", + " echo \\"$ bundle install --path /usr/local/__bundle\\"", + " bundle install --path /usr/local/__bundle", + " else", + " echo \\"$ bundle config set path /usr/local/__bundle\\"", + " bundle config set path /usr/local/__bundle", + " echo \\"$ bundle install\\"", + " bundle install", + " fi", + " echo \\"$ bundle clean\\"", + " bundle clean && echo \\"All clean!\\"", + "if [ -f \\"_cloudcannon-prebuild.sh\\" ]; then", + " echo \\"$ bash _cloudcannon-prebuild.sh\\"", + " echo \\"DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild\\"", + " bash -l _cloudcannon-prebuild.sh", + "fi", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + " echo \\"$ bundle exec jekyll build \\"", + " bundle exec jekyll build ", + "else", + "if [ -f \\"_cloudcannon-prebuild.sh\\" ]; then", + " echo \\"$ bash _cloudcannon-prebuild.sh\\"", + " echo \\"DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild\\"", + " bash -l _cloudcannon-prebuild.sh", + "fi", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + " echo \\"$ jekyll build \\";", + " jekyll build ", + "fi", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"_site\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"_site\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; diff --git a/tests/__snapshots__/reader-npm.test.js.snap b/tests/__snapshots__/reader-npm.test.js.snap new file mode 100644 index 0000000..af4d45b --- /dev/null +++ b/tests/__snapshots__/reader-npm.test.js.snap @@ -0,0 +1,111 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`outputs with @next config 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo '$ npm install'", + "npm install", + "echo '$ cd /usr/local/__site/src/'", + "cd /usr/local/__site/src/", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "echo '$ npm run build'", + "npm run build", + "echo '$ cd /usr/local/__site/src/'", + "cd /usr/local/__site/src/", + "__CURRENT_NVM_VERSION=$(nvm current)", + "nvm use default > /dev/null", + "echo '$ npx @cloudcannon/reader@next --output \\"public\\"'", + "npx @cloudcannon/reader@next --output \\"public\\"", + "nvm use \\"$__CURRENT_NVM_VERSION\\" > /dev/null", + "unset __CURRENT_NVM_VERSION", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"public\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"public\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; + +exports[`outputs with empty config 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo '$ npm install'", + "npm install", + "echo '$ cd /usr/local/__site/src/'", + "cd /usr/local/__site/src/", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "echo '$ npm run build'", + "npm run build", + "echo '$ cd /usr/local/__site/src/'", + "cd /usr/local/__site/src/", + "__CURRENT_NVM_VERSION=$(nvm current)", + "nvm use default > /dev/null", + "echo '$ npx @cloudcannon/reader@latest --output \\"public\\"'", + "npx @cloudcannon/reader@latest --output \\"public\\"", + "nvm use \\"$__CURRENT_NVM_VERSION\\" > /dev/null", + "unset __CURRENT_NVM_VERSION", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"public\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"public\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; diff --git a/tests/__snapshots__/reader.test.js.snap b/tests/__snapshots__/reader.test.js.snap new file mode 100644 index 0000000..f9d2c3d --- /dev/null +++ b/tests/__snapshots__/reader.test.js.snap @@ -0,0 +1,95 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`outputs with @next config 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "__CURRENT_NVM_VERSION=$(nvm current)", + "nvm use default > /dev/null", + "echo '$ npx @cloudcannon/reader@next --output \\"public\\"'", + "npx @cloudcannon/reader@next --output \\"public\\"", + "nvm use \\"$__CURRENT_NVM_VERSION\\" > /dev/null", + "unset __CURRENT_NVM_VERSION", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"public\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"public\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; + +exports[`outputs with empty config 1`] = ` +Array [ + "echo \\"$ source .cloudcannon/preinstall\\"", + "if [ -f \\".cloudcannon/preinstall\\" ]; then source .cloudcannon/preinstall; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "echo \\"$ source .cloudcannon/prebuild\\"", + "if [ -f \\".cloudcannon/prebuild\\" ]; then source .cloudcannon/prebuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "DETECTED_hugo_VERSION=$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)", + "echo \\"[🏷hugo:\${DETECTED_hugo_VERSION}]\\"", + "DETECTED_ruby_VERSION=$((ruby -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^ruby //g\\" | cut -d \\" \\" -f 1 | cut -d \\"p\\" -f 1)", + "echo \\"[🏷ruby:\${DETECTED_ruby_VERSION}]\\"", + "DETECTED_node_VERSION=$((node -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^v//\\")", + "echo \\"[🏷node:\${DETECTED_node_VERSION}]\\"", + "DETECTED_deno_VERSION=$((deno -V 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^deno //\\")", + "echo \\"[🏷deno:\${DETECTED_deno_VERSION}]\\"", + "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\")", + "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", + "DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo 'unknown') | sed \\"s/[][]//g\\" | sed \\"s/^Bundler version //g\\")", + "echo \\"[🏷npm:\${DETECTED_NPM_VERSION}]\\"", + "echo \\"[🏷yarn:\${DETECTED_YARN_VERSION}]\\"", + "echo \\"[🏷bundler:\${DETECTED_BUNDLE_VERSION}]\\"", + "__CURRENT_NVM_VERSION=$(nvm current)", + "nvm use default > /dev/null", + "echo '$ npx @cloudcannon/reader@latest --output \\"public\\"'", + "npx @cloudcannon/reader@latest --output \\"public\\"", + "nvm use \\"$__CURRENT_NVM_VERSION\\" > /dev/null", + "unset __CURRENT_NVM_VERSION", + "echo \\"$ source .cloudcannon/postbuild\\"", + "if [ -f \\".cloudcannon/postbuild\\" ]; then source .cloudcannon/postbuild; else echo \\"Not found.\\"; fi", + "echo \\"$ cd /usr/local/__site/src/\\"", + "cd /usr/local/__site/src/", + "find /usr/local/__site/compiled/ -mindepth 1 -delete", + "shopt -s dotglob extglob", + "__OUTPUT_DIR_CONTENT=$(ls \\"public\\")", + "[ -z \\"$__OUTPUT_DIR_CONTENT\\" ] || mv \\"public\\"/!(.cloudcannon|..|.) /usr/local/__site/compiled/", + "unset __OUTPUT_DIR_CONTENT", + "shopt -u dotglob extglob", + "echo \\"[☁️Start Export]\\"", + "echo \\"{\\"", + "echo \\"\\\\\\"syncPaths\\\\\\": \\\\\\"$SYNC_PATHS\\\\\\"\\"", + "echo \\"}\\"", +] +`; diff --git a/tests/eleventy.test.js b/tests/eleventy.test.js index df4db7e..88b44f6 100644 --- a/tests/eleventy.test.js +++ b/tests/eleventy.test.js @@ -1,219 +1,15 @@ const { runScriptCommands } = require('../src/lib/eleventy'); test('outputs with empty config', () => { - expect(runScriptCommands()).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'echo \'$ npm pkg set dependencies.eleventy-plugin-cloudcannon=latest || npm install eleventy-plugin-cloudcannon@latest\'', - 'npm pkg set dependencies.eleventy-plugin-cloudcannon=latest || npm install eleventy-plugin-cloudcannon@latest', - - 'echo \'$ npm install\'', - 'npm install', - - "export CC_ELEVENTY_VERSION=`npm list @11ty/eleventy | grep @11ty/eleventy | awk -F \"@\" '{print $NF}'`", - 'if [[ -z "$CC_ELEVENTY_VERSION" ]]; then export CC_ELEVENTY_VERSION=unknown; fi', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷@11ty/eleventy:${CC_ELEVENTY_VERSION}]"', - "echo '$ if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi'", - 'if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi', - "echo '$ if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi'", - 'if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi', - "echo '$ if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi'", - 'if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi', - "echo '$ if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi'", - 'if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi', - "echo '$ echo $CONFIG'", - 'echo $CONFIG', - "echo '$ CONFIG_DIR=`dirname $CONFIG`'", - 'CONFIG_DIR=`dirname $CONFIG`', - "echo '$ echo $CONFIG_DIR'", - 'echo $CONFIG_DIR', - "echo '$ PWD=`pwd`'", - 'PWD=`pwd`', - "echo '$ echo $PWD'", - 'echo $PWD', - "echo '$ CONFIG_BASE=`basename $CONFIG`'", - 'CONFIG_BASE=`basename $CONFIG`', - "echo '$ echo $CONFIG_BASE'", - 'echo $CONFIG_BASE', - "echo '$ CONFIG_INJECTED=\"$PWD/$CONFIG_DIR/inject-cloudcannon.config.cjs\"'", - 'CONFIG_INJECTED="$PWD/$CONFIG_DIR/inject-cloudcannon.config.cjs"', - "echo '$ echo $CONFIG_INJECTED'", - 'echo $CONFIG_INJECTED', - "echo '$ export CC_ELEVENTY_CONFIG=\"$PWD/$CONFIG_DIR/default-$CONFIG_BASE\"'", - 'export CC_ELEVENTY_CONFIG="$PWD/$CONFIG_DIR/default-$CONFIG_BASE"', - "echo '$ echo $CC_ELEVENTY_CONFIG'", - 'echo $CC_ELEVENTY_CONFIG', - "echo '$ if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi'", - 'if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi', - "echo '$ cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED'", - 'cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'DETECTED_NPM_VERSION=$(npm -v | sed \'s/[][]//g\')', - 'DETECTED_NODE_VERSION=$(node -v | sed \'s/[][]//g\' | sed \'s/^v//\')', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"', - - 'echo \'$ npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site\'', - 'npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site', - - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "_site")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "_site"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands()).toMatchSnapshot(); }); test('outputs with @next config', () => { expect(runScriptCommands({ use_beta_plugin: true, input: 'src', incremental: true, ignoreinitial: true - })).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'echo \'$ npm pkg set dependencies.eleventy-plugin-cloudcannon=next || npm install eleventy-plugin-cloudcannon@next\'', - 'npm pkg set dependencies.eleventy-plugin-cloudcannon=next || npm install eleventy-plugin-cloudcannon@next', - - 'echo \'$ npm install\'', - 'npm install', - - "export CC_ELEVENTY_VERSION=`npm list @11ty/eleventy | grep @11ty/eleventy | awk -F \"@\" '{print $NF}'`", - 'if [[ -z "$CC_ELEVENTY_VERSION" ]]; then export CC_ELEVENTY_VERSION=unknown; fi', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷@11ty/eleventy:${CC_ELEVENTY_VERSION}]"', - "echo '$ if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi'", - 'if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi', - "echo '$ if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi'", - 'if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi', - "echo '$ if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi'", - 'if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi', - "echo '$ if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi'", - 'if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi', - "echo '$ echo $CONFIG'", - 'echo $CONFIG', - "echo '$ CONFIG_DIR=`dirname $CONFIG`'", - 'CONFIG_DIR=`dirname $CONFIG`', - "echo '$ echo $CONFIG_DIR'", - 'echo $CONFIG_DIR', - "echo '$ PWD=`pwd`'", - 'PWD=`pwd`', - "echo '$ echo $PWD'", - 'echo $PWD', - "echo '$ CONFIG_BASE=`basename $CONFIG`'", - 'CONFIG_BASE=`basename $CONFIG`', - "echo '$ echo $CONFIG_BASE'", - 'echo $CONFIG_BASE', - "echo '$ CONFIG_INJECTED=\"$PWD/$CONFIG_DIR/inject-cloudcannon.config.cjs\"'", - 'CONFIG_INJECTED="$PWD/$CONFIG_DIR/inject-cloudcannon.config.cjs"', - "echo '$ echo $CONFIG_INJECTED'", - 'echo $CONFIG_INJECTED', - "echo '$ export CC_ELEVENTY_CONFIG=\"$PWD/$CONFIG_DIR/default-$CONFIG_BASE\"'", - 'export CC_ELEVENTY_CONFIG="$PWD/$CONFIG_DIR/default-$CONFIG_BASE"', - "echo '$ echo $CC_ELEVENTY_CONFIG'", - 'echo $CC_ELEVENTY_CONFIG', - "echo '$ if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi'", - 'if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi', - "echo '$ cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED'", - 'cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED', - - 'echo \'$ export CC_ELEVENTY_INPUT="src"\'', - 'export CC_ELEVENTY_INPUT="src"', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'DETECTED_NPM_VERSION=$(npm -v | sed \'s/[][]//g\')', - 'DETECTED_NODE_VERSION=$(node -v | sed \'s/[][]//g\' | sed \'s/^v//\')', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"', - - 'echo \'$ npx @11ty/eleventy --config=$CONFIG_INJECTED --input src --incremental --ignore-initial --output _site\'', - 'npx @11ty/eleventy --config=$CONFIG_INJECTED --input src --incremental --ignore-initial --output _site', - - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "_site")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "_site"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + })).toMatchSnapshot(); }); test('outputs with mange_plugin_manually', () => { - expect(runScriptCommands({ manage_plugin_manually: true })).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'echo \'$ npm install\'', - 'npm install', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'DETECTED_NPM_VERSION=$(npm -v | sed \'s/[][]//g\')', - 'DETECTED_NODE_VERSION=$(node -v | sed \'s/[][]//g\' | sed \'s/^v//\')', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"', - - "echo '$ npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site'", - 'npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site', - - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "_site")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "_site"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands({ manage_plugin_manually: true })).toMatchSnapshot(); }); diff --git a/tests/hugo.test.js b/tests/hugo.test.js index 189791c..2d7af7f 100644 --- a/tests/hugo.test.js +++ b/tests/hugo.test.js @@ -1,111 +1,9 @@ const { runScriptCommands } = require('../src/lib/hugo'); test('outputs with empty config', () => { - expect(runScriptCommands()).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - "echo '$ export NODE_PATH=`pwd`/node_modules:$NODE_PATH'", - 'export NODE_PATH=`pwd`/node_modules:$NODE_PATH', - "echo '$ [ -f package.json ] && npm i'", - '[ -f package.json ] && npm i', - "echo '$ cd /usr/local/__site/src/'", - 'cd /usr/local/__site/src/', - - 'if [ -f "_cloudcannon-prebuild.sh" ]; then', - ' echo "$ bash _cloudcannon-prebuild.sh"', - ' echo "DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild"', - ' bash -l _cloudcannon-prebuild.sh', - 'fi', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - "DETECTED_HUGO_VERSION=$(hugo version | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1)", - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷hugo:${DETECTED_HUGO_VERSION}]"', - - "echo '$ hugo --destination public'", - 'hugo --destination public', - '__CURRENT_NVM_VERSION=$(nvm current)', - 'nvm use default > /dev/null', - "echo '$ npx cloudcannon-hugo --destination public'", - 'npx cloudcannon-hugo --destination public', - 'nvm use "$__CURRENT_NVM_VERSION" > /dev/null', - 'unset __CURRENT_NVM_VERSION', - - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "public")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "public"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands()).toMatchSnapshot(); }); test('outputs with source directory configured', () => { - expect(runScriptCommands({ source: 'src' })).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - "echo '$ export NODE_PATH=`pwd`/node_modules:$NODE_PATH'", - 'export NODE_PATH=`pwd`/node_modules:$NODE_PATH', - "echo '$ [ -f package.json ] && npm i'", - '[ -f package.json ] && npm i', - "echo '$ cd /usr/local/__site/src/'", - 'cd /usr/local/__site/src/', - - 'if [ -f "_cloudcannon-prebuild.sh" ]; then', - ' echo "$ bash _cloudcannon-prebuild.sh"', - ' echo "DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild"', - ' bash -l _cloudcannon-prebuild.sh', - 'fi', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - "DETECTED_HUGO_VERSION=$(hugo version | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1)", - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷hugo:${DETECTED_HUGO_VERSION}]"', - - "echo '$ hugo --source src --destination public'", - 'hugo --source src --destination public', - '__CURRENT_NVM_VERSION=$(nvm current)', - 'nvm use default > /dev/null', - "echo '$ npx cloudcannon-hugo --source src --destination public'", - 'npx cloudcannon-hugo --source src --destination public', - 'nvm use "$__CURRENT_NVM_VERSION" > /dev/null', - 'unset __CURRENT_NVM_VERSION', - - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "src/public")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "src/public"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands({ source: 'src' })).toMatchSnapshot(); }); diff --git a/tests/jekyll.test.js b/tests/jekyll.test.js index d6f059e..6ec63ba 100644 --- a/tests/jekyll.test.js +++ b/tests/jekyll.test.js @@ -1,197 +1,10 @@ const { runScriptCommands } = require('../src/lib/jekyll'); test('outputs with empty config', () => { - expect(runScriptCommands()).toEqual([ - 'echo "$ export JEKYLL_ENV=\\"production\\""', - 'export JEKYLL_ENV="production"', - 'if [ -f ".ruby-version" ]; then', - ' echo "$ ruby -v (Using .ruby-version)"', - ' ruby -v || (echo "\\nPlease use one of the following versions:\\n" && rbenv versions 2> /dev/null && false)', - 'fi', - - 'DETECTED_BUNDLE_VERSION=$(bundle -v | sed \'s/[][]//g\' | sed \'s/^Bundler version //g\')', - 'DETECTED_RUBY_VERSION=$(ruby -v | sed \'s/[][]//g\' | sed \'s/^ruby //g\' | cut -d \' \' -f 1)', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷bundler:${DETECTED_BUNDLE_VERSION}]"', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷ruby:${DETECTED_RUBY_VERSION}]"', - - 'if [ -d "undefined" ]; then', - ' echo "$ rm -rf undefined"', - ' rm -rf undefined', - 'fi', - 'USE_BUNDLE=false', - 'if [ -f /usr/local/__site/src/"$BUNDLE_GEMFILE" ]; then', - ' echo "$ export BUNDLE_GEMFILE=/usr/local/__site/src/$BUNDLE_GEMFILE"', - ' export BUNDLE_GEMFILE=/usr/local/__site/src/"$BUNDLE_GEMFILE"', - ' USE_BUNDLE=true', - 'elif [ -f /usr/local/__site/src/Gemfile ]; then', - ' USE_BUNDLE=true', - 'fi', - - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'if [ "$USE_BUNDLE" = true ]; then', - ' echo "$ bundle version"', - ' bundle version', - ' echo "$ bundle config --global jobs 4"', - ' bundle config --global jobs 4 && echo "Configured concurrent installs!"', - ' echo "$ bundle config build.nokogiri --use-system-libraries"', - ' bundle config build.nokogiri --use-system-libraries && echo "Configured nokogiri flag!"', - ' echo "$ bundle install"', - ' bundle install', - - 'if [ -f "_cloudcannon-prebuild.sh" ]; then', - ' echo "$ bash _cloudcannon-prebuild.sh"', - ' echo "DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild"', - ' bash -l _cloudcannon-prebuild.sh', - 'fi', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - ' echo "$ bundle exec jekyll build "', - ' bundle exec jekyll build ', - 'else', - - 'if [ -f "_cloudcannon-prebuild.sh" ]; then', - ' echo "$ bash _cloudcannon-prebuild.sh"', - ' echo "DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild"', - ' bash -l _cloudcannon-prebuild.sh', - 'fi', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - ' echo "$ jekyll build ";', - ' jekyll build ', - 'fi', - - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "_site")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "_site"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands()).toMatchSnapshot(); }); test('outputs with enable_bundle_cache or use_local_bundle', () => { - const expected = [ - 'echo "$ export JEKYLL_ENV=\\"production\\""', - 'export JEKYLL_ENV="production"', - 'if [ -f ".ruby-version" ]; then', - ' echo "$ ruby -v (Using .ruby-version)"', - ' ruby -v || (echo "\\nPlease use one of the following versions:\\n" && rbenv versions 2> /dev/null && false)', - 'fi', - - 'DETECTED_BUNDLE_VERSION=$(bundle -v | sed \'s/[][]//g\' | sed \'s/^Bundler version //g\')', - 'DETECTED_RUBY_VERSION=$(ruby -v | sed \'s/[][]//g\' | sed \'s/^ruby //g\' | cut -d \' \' -f 1)', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷bundler:${DETECTED_BUNDLE_VERSION}]"', - // eslint-disable-next-line no-template-curly-in-string - 'echo "[🏷ruby:${DETECTED_RUBY_VERSION}]"', - - 'if [ -d "undefined" ]; then', - ' echo "$ rm -rf undefined"', - ' rm -rf undefined', - 'fi', - 'USE_BUNDLE=false', - 'if [ -f /usr/local/__site/src/"$BUNDLE_GEMFILE" ]; then', - ' echo "$ export BUNDLE_GEMFILE=/usr/local/__site/src/$BUNDLE_GEMFILE"', - ' export BUNDLE_GEMFILE=/usr/local/__site/src/"$BUNDLE_GEMFILE"', - ' USE_BUNDLE=true', - 'elif [ -f /usr/local/__site/src/Gemfile ]; then', - ' USE_BUNDLE=true', - 'fi', - - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - 'if [ "$USE_BUNDLE" = true ]; then', - ' echo "$ bundle version"', - ' bundle version', - ' echo "$ bundle config --global jobs 4"', - ' bundle config --global jobs 4 && echo "Configured concurrent installs!"', - ' echo "$ bundle config build.nokogiri --use-system-libraries"', - ' bundle config build.nokogiri --use-system-libraries && echo "Configured nokogiri flag!"', - ' if [[ $DETECTED_BUNDLE_VERSION == "1."* ]]; then', - ' echo "$ bundle install --path /usr/local/__bundle"', - ' bundle install --path /usr/local/__bundle', - ' else', - ' echo "$ bundle config set path /usr/local/__bundle"', - ' bundle config set path /usr/local/__bundle', - ' echo "$ bundle install"', - ' bundle install', - ' fi', - - ' echo "$ bundle clean"', - ' bundle clean && echo "All clean!"', - - 'if [ -f "_cloudcannon-prebuild.sh" ]; then', - ' echo "$ bash _cloudcannon-prebuild.sh"', - ' echo "DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild"', - ' bash -l _cloudcannon-prebuild.sh', - 'fi', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - ' echo "$ bundle exec jekyll build "', - ' bundle exec jekyll build ', - 'else', - - 'if [ -f "_cloudcannon-prebuild.sh" ]; then', - ' echo "$ bash _cloudcannon-prebuild.sh"', - ' echo "DEPRECATED: _cloudcannon-prebuild.sh should be moved to .cloudcannon/prebuild"', - ' bash -l _cloudcannon-prebuild.sh', - 'fi', - - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - - ' echo "$ jekyll build ";', - ' jekyll build ', - 'fi', - - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "_site")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "_site"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]; - - expect(runScriptCommands({ enable_bundle_cache: true })).toEqual(expected); - expect(runScriptCommands({ use_local_bundle: true })).toEqual(expected); + expect(runScriptCommands({ enable_bundle_cache: true })).toMatchSnapshot(); + expect(runScriptCommands({ use_local_bundle: true })).toMatchSnapshot(); }); diff --git a/tests/reader-npm.test.js b/tests/reader-npm.test.js index 6abf809..f372384 100644 --- a/tests/reader-npm.test.js +++ b/tests/reader-npm.test.js @@ -1,111 +1,9 @@ const { runScriptCommands } = require('../src/lib/reader-npm'); test('outputs with empty config', () => { - expect(runScriptCommands()).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - "echo '$ npm install'", - 'npm install', - "echo '$ cd /usr/local/__site/src/'", - 'cd /usr/local/__site/src/', - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \"s/[][]//g\")", - 'DETECTED_NODE_VERSION=$((node -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^v//")', - 'DETECTED_DENO_VERSION=$((deno -V 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^deno //")', - "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", - 'DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^Bundler version //g")', - 'DETECTED_RUBY_VERSION=$((ruby -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^ruby //g" | cut -d " " -f 1)', - /* eslint-disable no-template-curly-in-string */ - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"', - 'echo "[🏷deno:${DETECTED_DENO_VERSION}]"', - 'echo "[🏷yarn:${DETECTED_YARN_VERSION}]"', - 'echo "[🏷ruby-bundler:${DETECTED_BUNDLE_VERSION}]"', - 'echo "[🏷ruby:${DETECTED_RUBY_VERSION}]"', - /* eslint-enable no-template-curly-in-string */ - "echo '$ npm run build'", - 'npm run build', - "echo '$ cd /usr/local/__site/src/'", - 'cd /usr/local/__site/src/', - '__CURRENT_NVM_VERSION=$(nvm current)', - 'nvm use default > /dev/null', - "echo '$ npx @cloudcannon/reader --output \"public\"'", - 'npx @cloudcannon/reader --output "public"', - 'nvm use "$__CURRENT_NVM_VERSION" > /dev/null', - 'unset __CURRENT_NVM_VERSION', - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "public")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "public"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands()).toMatchSnapshot(); }); test('outputs with @next config', () => { - expect(runScriptCommands({ use_beta_plugin: true, input: 'src' })).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - "echo '$ npm install'", - 'npm install', - "echo '$ cd /usr/local/__site/src/'", - 'cd /usr/local/__site/src/', - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \"s/[][]//g\")", - 'DETECTED_NODE_VERSION=$((node -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^v//")', - 'DETECTED_DENO_VERSION=$((deno -V 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^deno //")', - "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", - 'DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^Bundler version //g")', - 'DETECTED_RUBY_VERSION=$((ruby -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^ruby //g" | cut -d " " -f 1)', - /* eslint-disable no-template-curly-in-string */ - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"', - 'echo "[🏷deno:${DETECTED_DENO_VERSION}]"', - 'echo "[🏷yarn:${DETECTED_YARN_VERSION}]"', - 'echo "[🏷ruby-bundler:${DETECTED_BUNDLE_VERSION}]"', - 'echo "[🏷ruby:${DETECTED_RUBY_VERSION}]"', - /* eslint-enable no-template-curly-in-string */ - "echo '$ npm run build'", - 'npm run build', - "echo '$ cd /usr/local/__site/src/'", - 'cd /usr/local/__site/src/', - '__CURRENT_NVM_VERSION=$(nvm current)', - 'nvm use default > /dev/null', - "echo '$ npx @cloudcannon/reader@next --output \"public\"'", - 'npx @cloudcannon/reader@next --output "public"', - 'nvm use "$__CURRENT_NVM_VERSION" > /dev/null', - 'unset __CURRENT_NVM_VERSION', - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "public")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "public"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands({ use_beta_plugin: true, input: 'src' })).toMatchSnapshot(); }); diff --git a/tests/reader.test.js b/tests/reader.test.js index 9e9dc0b..481919a 100644 --- a/tests/reader.test.js +++ b/tests/reader.test.js @@ -1,95 +1,9 @@ const { runScriptCommands } = require('../src/lib/reader'); test('outputs with empty config', () => { - expect(runScriptCommands()).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \"s/[][]//g\")", - 'DETECTED_NODE_VERSION=$((node -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^v//")', - 'DETECTED_DENO_VERSION=$((deno -V 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^deno //")', - "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", - 'DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^Bundler version //g")', - 'DETECTED_RUBY_VERSION=$((ruby -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^ruby //g" | cut -d " " -f 1)', - /* eslint-disable no-template-curly-in-string */ - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"', - 'echo "[🏷deno:${DETECTED_DENO_VERSION}]"', - 'echo "[🏷yarn:${DETECTED_YARN_VERSION}]"', - 'echo "[🏷ruby-bundler:${DETECTED_BUNDLE_VERSION}]"', - 'echo "[🏷ruby:${DETECTED_RUBY_VERSION}]"', - /* eslint-enable no-template-curly-in-string */ - '__CURRENT_NVM_VERSION=$(nvm current)', - 'nvm use default > /dev/null', - "echo '$ npx @cloudcannon/reader --output \"public\"'", - 'npx @cloudcannon/reader --output "public"', - 'nvm use "$__CURRENT_NVM_VERSION" > /dev/null', - 'unset __CURRENT_NVM_VERSION', - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "public")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "public"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands()).toMatchSnapshot(); }); test('outputs with @next config', () => { - expect(runScriptCommands({ use_beta_plugin: true, input: 'src' })).toEqual([ - 'echo "$ source .cloudcannon/preinstall"', - 'if [ -f ".cloudcannon/preinstall" ]; then source .cloudcannon/preinstall; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - 'echo "$ source .cloudcannon/prebuild"', - 'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - "DETECTED_NPM_VERSION=$((npm -v 2> /dev/null || echo 'unknown') | sed \"s/[][]//g\")", - 'DETECTED_NODE_VERSION=$((node -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^v//")', - 'DETECTED_DENO_VERSION=$((deno -V 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^deno //")', - "DETECTED_YARN_VERSION=$(yarn -v 2> /dev/null || echo 'unknown')", - 'DETECTED_BUNDLE_VERSION=$((bundle -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^Bundler version //g")', - 'DETECTED_RUBY_VERSION=$((ruby -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^ruby //g" | cut -d " " -f 1)', - /* eslint-disable no-template-curly-in-string */ - 'echo "[🏷npm:${DETECTED_NPM_VERSION}]"', - 'echo "[🏷node:${DETECTED_NODE_VERSION}]"', - 'echo "[🏷deno:${DETECTED_DENO_VERSION}]"', - 'echo "[🏷yarn:${DETECTED_YARN_VERSION}]"', - 'echo "[🏷ruby-bundler:${DETECTED_BUNDLE_VERSION}]"', - 'echo "[🏷ruby:${DETECTED_RUBY_VERSION}]"', - /* eslint-enable no-template-curly-in-string */ - '__CURRENT_NVM_VERSION=$(nvm current)', - 'nvm use default > /dev/null', - "echo '$ npx @cloudcannon/reader@next --output \"public\"'", - 'npx @cloudcannon/reader@next --output "public"', - 'nvm use "$__CURRENT_NVM_VERSION" > /dev/null', - 'unset __CURRENT_NVM_VERSION', - 'echo "$ source .cloudcannon/postbuild"', - 'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi', - 'echo "$ cd /usr/local/__site/src/"', - 'cd /usr/local/__site/src/', - 'find /usr/local/__site/compiled/ -mindepth 1 -delete', - 'shopt -s dotglob extglob', - '__OUTPUT_DIR_CONTENT=$(ls "public")', - '[ -z "$__OUTPUT_DIR_CONTENT" ] || mv "public"/!(.cloudcannon|..|.) /usr/local/__site/compiled/', - 'unset __OUTPUT_DIR_CONTENT', - 'shopt -u dotglob extglob', - 'echo "[☁️Start Export]"', - 'echo "{"', - 'echo "\\"syncPaths\\": \\"$SYNC_PATHS\\""', - 'echo "}"' - ]); + expect(runScriptCommands({ use_beta_plugin: true, input: 'src' })).toMatchSnapshot(); });