当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript js-yaml.dump函数代码示例

本文整理汇总了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);

}
开发者ID:hmenager,项目名称:composer,代码行数:27,代码来源:model-serializer.ts

示例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));
  }
开发者ID:june1123,项目名称:testSources,代码行数:25,代码来源:DataHelper.ts

示例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!
  `)
}
开发者ID:Blanket-Warriors,项目名称:Blog-O-Matic,代码行数:26,代码来源:postGenerator.ts

示例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\`)
  `)
}
开发者ID:Blanket-Warriors,项目名称:Blog-O-Matic,代码行数:33,代码来源:blogGenerator.ts

示例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;
  }
开发者ID:Narazaka,项目名称:xlsx2seed.js,代码行数:10,代码来源:xlsx2seed.ts

示例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)
  }
}
开发者ID:Nking92,项目名称:azure-rest-api-specs,代码行数:53,代码来源:multiapi.ts

示例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;
          },
开发者ID:gingerwizard,项目名称:kibana,代码行数:12,代码来源:tags.ts

示例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;
      });
开发者ID:robfletcher,项目名称:deck,代码行数:45,代码来源:manifestCommandBuilder.service.ts

示例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
}
开发者ID:dianpeng,项目名称:fly,代码行数:19,代码来源:file_app_store.ts

示例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);
	}
};
开发者ID:syuilo,项目名称:misskey-file,代码行数:94,代码来源:config-generator.ts

示例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');
开发者ID:Narazaka,项目名称:xlsx2seed.js,代码行数:29,代码来源:xlsx2seed.ts

示例12:

        const convertedConfig = knownConfigIds.reduce((blockObj: any, id: keyof ConfigContent) => {
          blockObj[id] =
            id === 'other' ? yaml.dump(omit(activeConfig, knownConfigIds)) : activeConfig[id];

          return blockObj;
        }, {});
开发者ID:salihkardan,项目名称:kibana,代码行数:6,代码来源:tags.ts

示例13: as_yaml

 as_yaml() {
   return jsyaml.dump(this.as_key_based());
 }
开发者ID:Narazaka,项目名称:xlsx2seed.js,代码行数:3,代码来源:xlsx2seed.ts

示例14:

 this.platformRepository.getApp(node.id, true).then(app => {
     savingUpdate.next("loaded");
     appType = app.class;
     return YAML.dump(app);
 }).then(text => {
开发者ID:hmenager,项目名称:composer,代码行数:5,代码来源:apps-panel.service.ts

示例15: dump

 return yamlDocuments.map(m => dump(m)).join('---\n');
开发者ID:emjburns,项目名称:deck,代码行数:1,代码来源:yamlEditorUtils.ts


注:本文中的js-yaml.dump函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。