v1.js
Cron to perform multiple imports from airtable to woocommerce. Imports products to woocommerce.
Should be run with command line arguments.
Example:node import-from-airtable-to-woocommerce-cron-v1.js \
conf-airtable-base-name= \
conf-airtable-table-name= \
conf-airtable-view-name= \
conf-airtable-api-key= \
conf-airtable-table-key= \
conf-airtable-key-name= \
conf-airtable-key-value= \
cron-airtable-base-name= \
cron-airtable-table-name= \
cron-airtable-view-name= \
cron-airtable-api-key= \
cron-airtable-table-key= \
cron-airtable-key-name= \
cron-airtable-key-value= \
console-key is read from airtable column itself. console-prefix is built automatically using both conf and cron keys.
Check also: https://console.ylo.one/
Airtable configuration schema table example: https://airtable.com/shrOSB0DFqir5c46L/tblL26Ms8WZWh6Uh0
Airtable cron schema table example: https://airtable.com/shrgvXVaLXQX1R7kU/tblyc4T3h51AxaUf8
Help: Coming soon! 😀
An app bundled by ac-bundle-app, published by ac-bundle-module. namespace: import-from-airtable-to-woocommerce-cron
Install from:
https://www.npmjs.com/package/import-from-airtable-to-woocommerce-cron-v1
https://github.com/animatedcreativity/import-from-airtable-to-woocommerce-cron-v1
Available Methods: start, startUps, workerStartUps, callbacks, api, build, cron, parseArgv, consoleColors, camelCase, properCase, workers, enhance, publish, utils, has
start
async function() {
var options = app.parseArgv(["conf-airtable-base-name", "conf-airtable-table-name", "conf-airtable-view-name", "conf-airtable-api-key", "conf-airtable-table-key", "conf-airtable-key-name", "conf-airtable-key-value", "cron-airtable-base-name", "cron-airtable-table-name", "cron-airtable-view-name", "cron-airtable-api-key", "cron-airtable-table-key", "cron-airtable-key-name", "cron-airtable-key-value"]);
if (app.has(options)) {
await app.cron.run.start(options);
} else {
console.log(app.consoleColors.bgRed, "Invalid options:", options);
}
}
startUps
workerStartUps
callbacks
static
api
airtable
build
cron
run
parseArgv
function(list) {
var options = {};
for (var i=2; i<=process.argv.length-1; i++) {
var option = process.argv[i];
var name = option.split("=").shift().trim();
var cName = app.camelCase(name).split("-").join("");
var value = option.split("=").pop().trim();
if (list.indexOf(name) >= 0) {
options[cName] = value;
} else {
console.log(app.consoleColors.bgRed, "Invalid option: " + name);
return;
}
}
return options;
}
consoleColors
reset, bright, dim, underscore, blink, reverse, hidden, fgBlack, fgRed, fgGreen, fgYellow, fgBlue, fgMagenta, fgCyan, fgWhite, fgGray, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray
camelCase
function camelize(str, capitalFirst) {
if (!app.has(capitalFirst)) capitalFirst = false;
var result = str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
}).replace(/\s+/g, '');
if (capitalFirst) result = result.substr(0, 1).toUpperCase() + result.substr(1, 999);
return result;
}
properCase
function(str) {
return str.replace(
/\w\S*/g,
function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }
);
}
workers
index, list, task, count, do
enhance
argv, console, string, workers
publish
utils
airtable
has
function(value) {
var found = true;
for (var i=0; i<=arguments.length-1; i++) {
var value = arguments[i];
if (!(typeof value !== "undefined" && value !== null && value !== "")) found = false;
}
return found;
}
Happy Coding!
MIT License: https://choosealicense.com/licenses/mit/
Copyright 2022 Animated Creativity
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.