Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
;
console.log('This scriprt is not working now. Should be fixed.');
cli.exit(1);
if (!to || !from) {
cli.error('"to" and "from" options are required.\n');
cli.output(cli.getUsage());
cli.exit(1);
return ;
}
var mongoUri = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || process.env.MONGO_URI || false;
if (!mongoUri) {
cli.error('Please set MONGO_URI env.\n');
cli.output(cli.getUsage());
cli.exit(1);
return;
}
mongo.connect(mongoUri);
// あー config 読み込み&model読み込み周りを app.js から切り離さないといけないにゃぁ
configModel = require('../lib/models/config')(app);
async.series([
function (next) {
configModel.loadAllConfig(function(err, doc) {
return next();
});
}, function (next) {
function watch (opts, args) {
const folder = localXdPath(opts);
if (!folder) {
console.fatal(`Could not determine Adobe XD folder.`);
return;
}
if (args.length === 0) {
args.push("."); // assume we want to install the plugin in the cwd
}
if (opts.json) {
// this doesn't make sense!
cli.output(JSON.stringify({"error": "Can't use JSON output on watch."}));
return;
}
opts.overwrite = true; // watch will always have to overwrite target plugins. Sorry.
const results = args.map(pluginToWatch => {
const sourcePath = path.resolve(pluginToWatch);
const result = {
path: sourcePath
};
const metadata = getPluginMetadata(sourcePath);
if (!metadata) {
return Object.assign({}, result, {
"error": "Can't watch a plugin that doesn't have a valid manifest.json"
});
cli.withInput(file, function (line, sep, eof) {
if (!eof) {
cli.output(line + sep);
} else if (cli.args.length) {
output_file(cli.args.shift());
}
});
};
includeEmpty: false,
}).filter(filterAlwaysIgnoredFile);
files.forEach(file => {
zipfile.addFile(path.join(sourcePath, file), file);
});
zipfile.end();
result.ok = `"${metadata.name}"@${metadata.version} [${metadata.id}] packaged successfully at ${result.targetZip}`;
return result;
});
if (opts.json) {
cli.output(JSON.stringify(results));
return results;
}
results.forEach(result => {
if (result.ok) {
cli.ok(result.ok);
} else {
cli.error(result.error);
}
});
return results;
}
});
}
const errors = validate(metadata, {root: sourcePath});
if (errors.length > 0) {
return Object.assign({}, result, {
"error": `Plugin ${pluginToValidate} has validation errors in the manifest.json:\n` + errors.join("\n")
});
}
result.ok = `"${metadata.name}"@${metadata.version} [${metadata.id}] validated successfully`;
return result;
});
if (opts.json) {
cli.output(JSON.stringify(results));
return results;
}
results.forEach(result => {
if (result.ok) {
cli.ok(result.ok);
} else {
cli.error(result.error);
}
});
return results;
}
}
cli.info(`Listing plugins inside ${folder}`);
const folders = shell.ls("-d", path.join(folder, "*"));
const plugins = folders.filter(pluginPath => {
const base = path.basename(pluginPath);
const metadata = getPluginMetadata(pluginPath);
if (args.length > 0 && metadata && (!args.includes(base) && !args.includes(metadata.id))) {
return false;
}
if (metadata && !opts.json) {
cli.output(`${base}: "${metadata.name}"@${metadata.version} [${metadata.id}]`);
}
return !!metadata;
});
if (opts.json) {
cli.output(JSON.stringify(plugins.map(pluginPath => ({
path: pluginPath,
metadata: getPluginMetadata(pluginPath)
})), null, 2));
}
if (plugins.length === 0) {
cli.error(`No valid plugins installed.`);
}
}
cli.withInput(file, function (line, sep, eof) {
if (!eof) {
cli.output(line + sep);
} else if (cli.args.length) {
output_file(cli.args.shift());
}
});
};