本文整理汇总了TypeScript中js-yaml.dump函数的典型用法代码示例。如果您正苦于以下问题:TypeScript dump函数的具体用法?TypeScript dump怎么用?TypeScript dump使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dump函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: serializeModel
export function serializeModel(model: CommandLineToolModel | WorkflowModel, embedReferences = true, asYaml = false, deleteSBGJob = false) {
let obj;
if (embedReferences && model instanceof WorkflowModel) {
obj = model.serializeEmbedded();
} else {
obj = model.serialize();
}
if (deleteSBGJob) {
delete obj["sbg:job"];
}
if (asYaml) {
return Yaml.dump(obj, {
json: true,
} as DumpOptions);
}
return JSON.stringify(obj, (key, value) => {
if (typeof value === "string") {
return value.replace(/\u2002/g, " ");
}
return value;
}, 4);
}
示例2: describeTablesToYaml
static async describeTablesToYaml() {
const json = await DBUtils.describeTables();
const description = _.map(json, (table: any) => {
const ignoreAttrs = ['TableStatus', 'CreationDateTime', 'TableSizeBytes', 'ItemCount', 'TableArn', 'IndexSizeBytes',
'IndexArn', 'IndexStatus', 'LastIncreaseDateTime', 'LastDecreaseDateTime', 'NumberOfDecreasesToday'];
for (const attrs of ignoreAttrs) {
delete table.Table[attrs];
if (table.Table.LocalSecondaryIndexes) {
for (const index of table.Table.LocalSecondaryIndexes) {
delete index[attrs];
}
}
if (table.Table.GlobalSecondaryIndexes) {
for (const index of table.Table.GlobalSecondaryIndexes) {
delete index[attrs];
}
}
}
return table;
});
fs.writeFileSync('table.yml', yaml.dump(description));
}
示例3: postGenerator
export async function postGenerator() {
console.log("\n😳 😳 🤖 😳 LET'S MAKE A BLOG POST! 😳 😳 🤖 😳 \n")
const config = load(fs.readFileSync("./blog.config.yml", "utf8")) || {}
const { author = "", title = "" } = await prompt([
q.postTitle,
{ ...q.postAuthor, default: config.author || "" },
]) as IPost
const id = title
.replace(",", "")
.replace(/[^a-zA-Z0-9_.@()-]/g, "-")
.toLowerCase()
const permalink = join("posts", `${id}.md`)
const now = new Date()
const postData = { author, id, permalink, title, created: now, updated: now }
const frontmatter = `---\n${dump(postData)}---\n`
await writeFile(permalink, frontmatter + `# ${title}\n`)
console.log(`
Congratulations! 🎉 🎉 🎉
You generated a blog post!
`)
}
示例4: blogGenerator
export async function blogGenerator() {
console.log("\n😳😳🤖😳 WELCOME TO BLOG-O-MATIC! 😳😳🤖😳\n")
const config = await prompt([
q.blogAuthor,
q.blogTitle,
q.blogPublisher,
]) as IConfig
Object.assign(config, { version: "4.0.0" })
if (config.publisher && publisherQuestions[config.publisher]) {
Object.assign(config, {
[config.publisher]: await prompt(publisherQuestions[config.publisher]),
})
}
await mkdir(config.title)
await Promise.all([
writeFile(join(config.title, "blog.config.yml"), dump(config)),
writeFile(join(config.title, ".blogignore"), ignoreText),
mkdir(join(config.title, "images")),
mkdir(join(config.title, "posts")),
])
console.log(`
Congratulations! 🎉 🎉 🎉
Blog-o-Matic successfully created your edit folder!
You can write whatever you want in here!
(Or if you're lazy like us, you can run \`blog post\`)
`)
}
示例5: as_separated_yaml
as_separated_yaml(cut_prefix = 0, cut_postfix = 0) {
const separated_records = this.as_separated_key_based(cut_prefix, cut_postfix);
const separated_yamls: {[key: string]: string} = {};
for (const key in separated_records) { // tslint:disable-line forin
const records = separated_records[key];
separated_yamls[key] = jsyaml.dump(records);
}
return separated_yamls;
}
示例6: async
const main = async (dir: string) => {
try {
const list = fs.recursiveReaddir(dir)
for await (const file of list) {
const f = path.parse(file)
if (f.base === "readme.md") {
console.log(`processing ${file}`)
const content = (await fs.readFile(file)).toString()
const readMe = cm.parse(content)
const set = new Set<string>()
for (const c of cm.iterate(readMe.markDown)) {
if (
c.type === "code_block" &&
c.info !== null &&
c.info.startsWith("yaml") &&
c.literal !== null
) {
const y = (yaml.load(c.literal) as Code)["input-file"]
if (typeof y === "string") {
set.add(y)
} else if (it.isArray(y)) {
for (const i of y) {
set.add(i)
}
}
}
}
const readMeMulti = cm.createNode(
"document",
cm.createNode(
"heading",
cm.createText("Multi-API support for AutoRest v3 generators")
),
cm.createNode(
"block_quote",
cm.createNode(
"paragraph",
cm.createText("see https://aka.ms/autorest")
)
),
cm.createCodeBlock(
"yaml $(enable-multi-api)",
yaml.dump({ "input-file": it.toArray(set) }, { lineWidth: 1000 })
)
)
const x = cm.markDownExToString({ markDown: readMeMulti })
fs.writeFile(path.join(f.dir, "readme.enable-multi-api.md"), x)
}
}
} catch (e) {
console.error(e)
}
}
示例7: set
(blockObj: any, id: keyof ConfigContent, index: number) => {
const unhydratedKey = hydratedIds[index];
set(
blockObj,
id,
id === 'other'
? yaml.dump(omit(activeConfig, knownConfigIds))
: get(activeConfig, unhydratedKey)
);
return blockObj;
},
示例8: dump
.then((backingData: any) => {
const accountData = backingData.accounts[0];
let account: string = null;
if (accountData) {
account = accountData.name;
}
let manifestArtifactAccount: string = null;
const artifactAccountData = backingData.artifactAccounts[0];
if (artifactAccountData) {
manifestArtifactAccount = artifactAccountData.name;
}
const manifest: any = null;
const manifests: any = null;
const manifestText = !sourceManifest ? '' : dump(sourceManifest);
const cloudProvider = 'kubernetes';
const moniker = sourceMoniker || {
app: app.name,
};
const relationships = {
loadBalancers: [] as string[],
securityGroups: [] as string[],
};
const versioned: any = null;
return {
command: {
cloudProvider,
manifest,
manifests,
relationships,
moniker,
account,
versioned,
manifestArtifactAccount,
},
metadata: {
backingData,
manifestText,
}
} as IKubernetesManifestCommandData;
});
示例9: buildConfig
function buildConfig(sourceDir: string, buildDir: string, env: string) {
const sourceFile = path.join(sourceDir, configFile)
const outFile = path.join(buildDir, configFileOutput)
let config: any = {}
if (fs.existsSync(sourceFile)) {
const inputConfig = YAML.load(fs.readFileSync(sourceFile).toString()) || {}
config = inputConfig[env] || inputConfig || {}
}
config.app = config.app_id || config.app || sourceDir
config.files = expandFiles(sourceDir, config.files || [])
config.config = config.config || {}
fs.writeFileSync(outFile, YAML.dump(config))
return config
}
示例10: function
export default async function(): Promise<void> {
const as: any = await inquirer.prompt([
{
type: 'input',
name: 'maintainer',
message: 'Maintainer name(and email address):'
},
{
type: 'input',
name: 'port',
message: 'Listen port:'
},
{
type: 'confirm',
name: 'https',
message: 'Use TLS?',
default: false
},
{
type: 'input',
name: 'https_key',
message: 'Path of tls key:',
when: (ctx: any): boolean => ctx.https
},
{
type: 'input',
name: 'https_cert',
message: 'Path of tls cert:',
when: (ctx: any): boolean => ctx.https
},
{
type: 'input',
name: 'https_ca',
message: 'Path of tls ca:',
when: (ctx: any): boolean => ctx.https
},
{
type: 'input',
name: 'mongo_host',
message: 'MongoDB\'s host:',
default: 'localhost'
},
{
type: 'input',
name: 'mongo_port',
message: 'MongoDB\'s port:',
default: '27017'
},
{
type: 'input',
name: 'mongo_db',
message: 'MongoDB\'s db:',
default: 'misskey'
},
{
type: 'input',
name: 'mongo_user',
message: 'MongoDB\'s user:'
},
{
type: 'password',
name: 'mongo_pass',
message: 'MongoDB\'s password:'
}
]);
const conf: IConfig = {
maintainer: as.maintainer,
port: parseInt(as.port, 10),
https: {
enable: as.https,
key: as.https_key || null,
cert: as.https_cert || null,
ca: as.https_ca || null
},
mongodb: {
host: as.mongo_host,
port: parseInt(as.mongo_port, 10),
db: as.mongo_db,
user: as.mongo_user,
pass: as.mongo_pass
}
};
console.log('Thanks, writing...');
try {
fs.mkdirSync(configDirPath);
fs.writeFileSync(configPath, yaml.dump(conf));
console.log('Well done.');
} catch (e) {
console.error(e);
}
};
示例11:
_console.log(' sheets:');
for (const sheet_name of xlsx2seed.sheet_names) {
if (only_sheets && !only_sheets[sheet_name]) continue;
_console.log(` ${sheet_name}:`);
if (ignore_sheets[sheet_name]) {
_console.log(' ignore: skip');
continue;
}
const sheet = xlsx2seed.sheet(sheet_name, config);
if (!sheet.has_id_column()) {
_console.log(' warning: id column not found -> skip!');
continue;
}
const {cut_prefix, cut_postfix} = subdivide_rules[sheet_name] || {cut_prefix: false, cut_postfix: false};
if (cut_prefix !== false || cut_postfix !== false)
_console.log(` subdivide: {cut_prefix: ${Number(cut_prefix)}, cut_postfix: ${Number(cut_postfix)}}`);
_console.time(' writetime');
const data = sheet.data(program.requireVersion);
if (program.stdout) {
const output_data: {[name: string]: KeyBasedRecord} = {};
output_data[sheet_name] = data.as_key_based();
console.log(jsyaml.dump(output_data));
} else {
data.write_as_single_or_separated_yaml_sync(program.output, cut_prefix, cut_postfix);
}
_console.timeEnd(' writetime');
}
}
_console.timeEnd('total');
示例12:
const convertedConfig = knownConfigIds.reduce((blockObj: any, id: keyof ConfigContent) => {
blockObj[id] =
id === 'other' ? yaml.dump(omit(activeConfig, knownConfigIds)) : activeConfig[id];
return blockObj;
}, {});
示例13: as_yaml
as_yaml() {
return jsyaml.dump(this.as_key_based());
}
示例14:
this.platformRepository.getApp(node.id, true).then(app => {
savingUpdate.next("loaded");
appType = app.class;
return YAML.dump(app);
}).then(text => {
示例15: dump
return yamlDocuments.map(m => dump(m)).join('---\n');