-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
356 changed files
with
16,083 additions
and
7,916 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"registeredExtensions": [ | ||
"payment-klarna-bridge" | ||
], | ||
"klarna": { | ||
"merchant_urls": { | ||
"id": "200", | ||
"terms": "https://example.com/terms", | ||
"checkout": "https://example.com/checkout?sid={checkout.order.id}", | ||
"confirmation": "https://example.com/api/ext/payment-klarna-example/confirmation?sid={checkout.order.id}", | ||
"push": "https://example.com/api/ext/payment-klarna-example/push?uri={checkout.order.id}", | ||
"validation": "https://example.com/api/ext/payment-klarna/validation", | ||
"shipping_option_update": "https://example.com/api/ext/payment-klarna-example/shipping_option_update", | ||
"address_update": "https://example.com/api/ext/payment-klarna/address_update", | ||
"notification": "https://example.com/api/ext/payment-klarna/notification" | ||
}, | ||
"name": "VSF Payment Klarna", | ||
"auth": { | ||
"user": "PK05273_caa011a9eda3", | ||
"pass": "TSL8CTtBVK9y8p76" | ||
}, | ||
"endpoints": { | ||
"orders": "https://api.playground.klarna.com/checkout/v3/orders" | ||
} | ||
}, | ||
"magento2": { | ||
"url": "http://demo-magento2.vuestorefront.io", | ||
"imgUrl": "http://demo-magento2.vuestorefront.io/pub/media/catalog/product", | ||
"assetPath": "/../var/magento2-sample-data/pub/media", | ||
"magentoUserName": "", | ||
"magentoUserPassword": "", | ||
"httpUserName": "", | ||
"httpUserPassword": "", | ||
"api": { | ||
"url": "http://demo-magento2.vuestorefront.io/rest", | ||
"consumerKey": "byv3730rhoulpopcq64don8ukb8lf2gq", | ||
"consumerSecret": "u9q4fcobv7vfx9td80oupa6uhexc27rb", | ||
"accessToken": "040xx3qy7s0j28o3q0exrfop579cy20m", | ||
"accessTokenSecret": "7qunl3p505rubmr7u1ijt7odyialnih9" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"strict": false, | ||
"allowJs": true, | ||
"importHelpers": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"esModuleInterop": true, | ||
"resolveJsonModule": false, | ||
"outDir": "dist", | ||
"sourceMap": true, | ||
"baseUrl": ".", | ||
"lib": ["es7", "dom"] | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* eslint-disable no-console */ | ||
const yaml = require('js-yaml') | ||
const path = require('path') | ||
const get = require('lodash.get') | ||
const fs = require('fs-extra') | ||
|
||
const prefix = './.output/' | ||
|
||
const getSrc = _src => path.resolve(process.cwd(), './', _src) | ||
const getDest = (_dest, service) => path.resolve(process.cwd(), prefix, _dest.replace('/var/www', service)) | ||
|
||
function copy (_src, _dest, service = '') { | ||
const src = getSrc(_src) | ||
const dest = getDest(_dest, service) | ||
console.log(`📂 Copying ${path.basename(src)} to ${dest}`) | ||
fs.copySync(src, dest, { | ||
filter: (_path) => !_path.includes('node_modules') | ||
}) | ||
} | ||
|
||
function createFileList () { | ||
const config = { | ||
files: [ | ||
'docker-compose.override.yml', | ||
'docker-compose.yml' | ||
] | ||
} | ||
console.log('🗒️ Creating config from the following files:\n🗒️ ', config.files.join('\n🗒️ ')) | ||
|
||
const services = {} | ||
config.files.filter(Boolean).forEach(file => { | ||
var doc = yaml.safeLoad(fs.readFileSync(file, 'utf8')) | ||
Object.entries(doc.services).map(([id, object]) => { | ||
if (services[id]) { | ||
services[id].bundle = get(object, 'labels.bundle', services[id].bundle) | ||
services[id].context = get(object, 'build.context', services[id].context) | ||
services[id].volumes = [...services[id].volumes, ...get(object, 'volumes', [])] | ||
services[id].volumesLast = [...services[id].volumesLast, ...get(object, 'volumesLast', [])] | ||
} else { | ||
services[id] = { | ||
bundle: get(object, 'labels.bundle'), | ||
context: get(object, 'build.context'), | ||
volumes: get(object, 'volumes', []), | ||
volumesLast: get(object, 'volumesLast', []) | ||
} | ||
} | ||
}) | ||
}) | ||
const array = Object.entries(services) | ||
.map(([id, object]) => ({id, ...object})) | ||
.filter(service => service.bundle) | ||
return array.map(service => ({ | ||
...service, | ||
volumes: [...service.volumes, ...service.volumesLast] | ||
})) | ||
} | ||
|
||
module.exports = { | ||
createFileList, | ||
copy, | ||
prefix, | ||
getSrc, | ||
getDest | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* eslint-disable no-console */ | ||
const {createFileList, copy, prefix, getDest} = require('./helpers') | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const program = require('commander') | ||
const merge = require('deepmerge') | ||
|
||
program | ||
.option('-e, --environment <env>', 'which config to build') | ||
|
||
program.parse(process.argv) | ||
|
||
const services = createFileList() | ||
services.forEach(service => { | ||
console.log('🗑️ Removing old files for service ' + service.id + '...') | ||
fs.removeSync(path.resolve(process.cwd(), prefix, service.bundle)) | ||
}) | ||
services.forEach(service => { | ||
// copy context if any | ||
if (service.context) { | ||
console.log('📂 Copying context for service ' + service.id + '...') | ||
copy(service.context, service.bundle) | ||
} | ||
service.volumes.map(volume => { | ||
const [src, dest] = volume.split(':') | ||
copy(src, dest, service.bundle) | ||
}) | ||
const { environment } = program | ||
if (environment === 'production' || environment === 'staging') { | ||
const baseConfigVolume = service.volumes.find(volume => volume.includes('base.json')) | ||
if (baseConfigVolume) { | ||
let [baseConfig, configTarget] = baseConfigVolume.split(':') | ||
configTarget = getDest(configTarget, service.bundle) | ||
const mergeConfig = baseConfig.replace('base.json', `${environment}.json`) | ||
if (fs.existsSync(mergeConfig)) { | ||
const baseFile = fs.readFileSync(baseConfig, 'utf8') | ||
const mergeFile = fs.readFileSync(mergeConfig, 'utf8') | ||
const newFile = merge(JSON.parse(baseFile), JSON.parse(mergeFile)) | ||
fs.writeFileSync(configTarget, JSON.stringify(newFile, null, 2)) | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "@kodbruket/docker-compose-bundler", | ||
"version": "0.1.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"commander": "^3.0.0", | ||
"deepmerge": "^4.0.0", | ||
"fs-extra": "^7.0.1", | ||
"js-yaml": "^3.13.1", | ||
"lodash.get": "^4.4.2", | ||
"sane": "^4.1.0" | ||
} | ||
} |
Oops, something went wrong.