How to use CommitFields method in argos

Best JavaScript code snippet using argos

release_notes.ts

Source:release_notes.ts Github

copy

Full Screen

1#!/usr/bin/env node2/**3 * @license4 * Copyright 2018 Google LLC. All Rights Reserved.5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 * =============================================================================17 */18/**19 * Generates a draft release notes markdown file for a release. This script20 * takes a start version of the union package, and optionally an end version.21 * It then finds the matching versions for all the dependency packages, and22 * finds all commit messages between those versions.23 *24 * The release notes are grouped by repository, and then bucketed by a set of25 * tags which committers can use to organize commits into sections. See26 * DEVELOPMENT.md for more details on the available tags.27 *28 * This script will ask for your github token which is used to make requests29 * to the github API for usernames for commits as this is not stored in git30 * logs. You can generate a token for your account here;31 * https://github.com/settings/tokens32 *33 * Usage:34 * yarn release-notes35 */36import * as argparse from 'argparse';37import * as fs from 'fs';38import * as util from './util';39import {$, Commit, Repo, RepoCommits} from './util';40// tslint:disable-next-line:no-require-imports41const octokit = require('@octokit/rest')();42const OUT_FILE = 'release-notes.md';43const TFJS_REPOS: Repo[] = [44 {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'},45 {name: 'Data', identifier: 'tfjs', path: 'tfjs-data'},46 {name: 'Layers', identifier: 'tfjs', path: 'tfjs-layers'},47 {name: 'Converter', identifier: 'tfjs', path: 'tfjs-converter'},48 {name: 'Node', identifier: 'tfjs', path: 'tfjs-node'},49 {name: 'Wasm', identifier: 'tfjs', path: 'tfjs-backend-wasm'},50 {name: 'Cpu', identifier: 'tfjs', path: 'tfjs-backend-cpu'},51 {name: 'Webgl', identifier: 'tfjs', path: 'tfjs-backend-webgl'}52];53const VIS_REPO: Repo = {54 name: 'tfjs-vis',55 identifier: 'tfjs-vis',56 path: 'tfjs-vis',57};58const RN_REPO: Repo = {59 name: 'tfjs-react-native',60 identifier: 'tfjs-react-native',61 path: 'tfjs-react-native',62};63async function askUserForVersions(validVersions: string[], packageName: string):64 Promise<{startVersion: string, endVersion: string}> {65 const YELLOW_TERMINAL_COLOR = '\x1b[33m%s\x1b[0m';66 const RED_TERMINAL_COLOR = '\x1b[31m%s\x1b[0m';67 console.log(YELLOW_TERMINAL_COLOR, packageName + ' versions');68 console.log(validVersions.join(', '));69 const startVersion = await util.question(`Enter the start version: `);70 if (validVersions.indexOf(startVersion) === -1) {71 console.log(RED_TERMINAL_COLOR, `Unknown start version: ${startVersion}`);72 process.exit(1);73 }74 const defaultVersion = validVersions[validVersions.length - 1];75 let endVersion = await util.question(76 `Enter the end version (leave empty for ${defaultVersion}): `);77 if (endVersion === '') {78 endVersion = defaultVersion;79 }80 if (validVersions.indexOf(endVersion) === -1) {81 console.log(RED_TERMINAL_COLOR, `Unknown end version: ${endVersion}`);82 process.exit(1);83 }84 return {startVersion, endVersion};85}86function getTaggedVersions(packageName: string) {87 const versions =88 $(`git tag`)89 .split('\n')90 .filter(x => new RegExp('^' + packageName + '-v([0-9])').test(x))91 .map(x => x.substring((packageName + '-v').length));92 return versions;93}94function getTagName(packageName: string, version: string) {95 return packageName + '-v' + version;96}97async function generateTfjsPackageNotes() {98 // Get union start version and end version.99 const identifier = 'tfjs';100 const versions = getTaggedVersions(identifier);101 const {startVersion, endVersion} =102 await askUserForVersions(versions, identifier);103 const startCommit =104 `git rev-list -n 1 ` + getTagName(identifier, startVersion);105 // Populate start and end for each of the tfjs packages.106 TFJS_REPOS.forEach(repo => {107 // Find the version of the dependency from the package.json from the108 // earliest tfjs tag.109 repo.startCommit = startCommit;110 repo.startVersion = startVersion;111 repo.endVersion = endVersion;112 });113 await generateNotes(TFJS_REPOS);114}115async function generateVisNotes() {116 // Get union start version and end version.117 const versions = getTaggedVersions('tfjs-vis');118 const {startVersion, endVersion} =119 await askUserForVersions(versions, 'tfjs-vis');120 // Get tfjs-vis start version and end version.121 VIS_REPO.startVersion = startVersion;122 VIS_REPO.endVersion = endVersion;123 VIS_REPO.startCommit = $(`git rev-list -n 1 ${124 getTagName(VIS_REPO.identifier, VIS_REPO.startVersion)}`);125 await generateNotes([VIS_REPO]);126}127async function generateReactNativeNotes() {128 // Get start version and end version.129 const versions = getTaggedVersions('tfjs-react-native');130 const {startVersion, endVersion} =131 await askUserForVersions(versions, 'tfjs-react-native');132 // Get tfjs-vis start version and end version.133 RN_REPO.startVersion = startVersion;134 RN_REPO.endVersion = endVersion;135 RN_REPO.startCommit = $(`git rev-list -n 1 ${136 getTagName(RN_REPO.identifier, RN_REPO.startVersion)}`);137 await generateNotes([RN_REPO]);138}139async function generateNotes(repositories: util.Repo[]) {140 const repoCommits: RepoCommits[] = [];141 // Clone all of the dependencies into the tmp directory.142 repositories.forEach(repo => {143 console.log(144 `${repo.name}: ${repo.startVersion}` +145 ` =====> ${repo.endVersion}`);146 console.log('Querying commits...');147 // Get subjects, bodies, emails, etc from commit metadata.148 const commitFieldQueries = ['%s', '%b', '%aE', '%H'];149 const commitFields = commitFieldQueries.map(query => {150 // Use a unique delimiter so we can split the log.151 const uniqueDelimiter = '--^^&&';152 const versionQuery = repo.startVersion != null ?153 `${getTagName(repo.identifier, repo.startVersion)}..` +154 `${getTagName(repo.identifier, repo.endVersion)}` :155 `#${repo.startCommit}..${156 getTagName(repo.identifier, repo.endVersion)}`;157 return $(`git log --pretty=format:"${query}${uniqueDelimiter}" ` +158 `${versionQuery}`)159 .trim()160 .split(uniqueDelimiter)161 .slice(0, -1)162 .map(str => str.trim());163 });164 const commits: Commit[] = [];165 for (let i = 0; i < commitFields[0].length; i++) {166 // Make sure the files touched contain the repo directory.167 const filesTouched =168 $(`git show --pretty="format:" --name-only ${commitFields[3][i]}`)169 .split('\n');170 let touchedDir = false;171 for (let j = 0; j < filesTouched.length; j++) {172 if (filesTouched[j].startsWith(repo.path)) {173 touchedDir = true;174 break;175 }176 }177 if (!touchedDir) {178 continue;179 }180 commits.push({181 subject: commitFields[0][i],182 body: commitFields[1][i],183 authorEmail: commitFields[2][i],184 sha: commitFields[3][i]185 });186 }187 repoCommits.push({188 repo,189 startVersion: repo.startVersion,190 endVersion: repo.endVersion,191 startCommit: repo.startCommit,192 commits193 });194 });195 // Ask for github token.196 const token = await util.question(197 'Enter GitHub token (https://github.com/settings/tokens): ');198 octokit.authenticate({type: 'token', token});199 const notes = await util.getReleaseNotesDraft(octokit, repoCommits);200 fs.writeFileSync(OUT_FILE, notes);201 console.log('Done writing notes to', OUT_FILE);202 // So the script doesn't just hang.203 process.exit(0);204}205const parser = new argparse.ArgumentParser();206parser.addArgument('--project', {207 help:208 'Which project to generate release notes for. One of union|vis. Defaults to union.',209 defaultValue: 'union',210 choices: ['union', 'vis', 'rn']211});212const args = parser.parseArgs();213if (args.project === 'union') {214 generateTfjsPackageNotes();215} else if (args.project === 'vis') {216 generateVisNotes();217} else if (args.project === 'rn') {218 generateReactNativeNotes();...

Full Screen

Full Screen

Commit.spec.ts

Source:Commit.spec.ts Github

copy

Full Screen

1import { alter, explain } from './TestUtils';2import Commit, { ICommitFields } from '../src/Commit';3import ICommitSigner from './crypto/ICommitSigner';4import SignedCommit from '../src/SignedCommit';5const commitFields: ICommitFields = {6 protected: {7 interface: 'Collections',8 context: 'schema.org',9 type: 'MusicPlaylist',10 operation: 'create',11 committed_at: '2019-01-01',12 commit_strategy: 'basic',13 sub: 'did:example:sub.id'14 },15 payload: {16 title: 'My Playlist',17 },18 header: {19 rev: 'abc',20 },21};22const commit = new Commit(commitFields);23describe('Commit', () => {24 describe('validate', () => {25 const invalidStrings = ['', null, undefined, true, false, 7, [], [''], {}];26 const invalidCases: {[field: string]: any[]} = {27 'protected.interface': invalidStrings,28 'protected.context': invalidStrings,29 'protected.type': invalidStrings,30 'protected.committed_at': invalidStrings,31 'protected.commit_strategy': invalidStrings,32 'protected.sub': invalidStrings,33 'protected.operation': [...invalidStrings, 'other'],34 'protected': [true, false, null, undefined, {}, [], 77],35 'payload': [true, false, null, undefined, 77],36 };37 Object.keys(invalidCases).forEach((field) => {38 const cases = invalidCases[field];39 cases.forEach(invalidValue => {40 it(`should reject '${field}' set to ${explain(invalidValue)}`, async () => {41 const alteredFields = alter(commitFields, { [field]: invalidValue });42 const commit = new Commit(alteredFields);43 expect(commit.isValid()).toBeFalsy();44 });45 });46 });47 it('should ensure object_id is not set for a create commit', async () => {48 const alteredFields = alter(commitFields, {49 'protected.operation': 'create',50 'protected.object_id': 'abc'51 });52 const commit = new Commit(alteredFields);53 expect(commit.isValid()).toBeFalsy();54 });55 it('should ensure object_id is set for an update/delete commit', async () => {56 ['update', 'delete'].forEach((operation) => {57 const alteredFields = alter(commitFields, {58 'protected.operation': operation,59 'protected.object_id': undefined60 });61 const commit = new Commit(alteredFields);62 expect(commit.isValid()).toBeFalsy();63 });64 });65 it('should validate a correct commit', async () => {66 const commit = new Commit(commitFields);67 expect(commit.isValid()).toBeTruthy();68 });69 });70 describe('getProtectedHeaders()', () => {71 it('should return the protected headers', async () => {72 expect(commit.getProtectedHeaders()).toEqual(commitFields.protected);73 });74 });75 describe('getUnprotectedHeaders()', () => {76 it('should return the unprotected headers', async () => {77 expect(commit.getUnprotectedHeaders()).toEqual(commitFields.header as any);78 });79 });80 describe('getPayload()', () => {81 it('should return the payload', async () => {82 expect(commit.getPayload()).toEqual(commitFields.payload);83 });84 });85 describe('sign()', () => {86 it('should call sign() on the given signer', async () => {87 const signedCommit = new SignedCommit({88 protected: '',89 payload: '',90 signature: '',91 });92 const signer: ICommitSigner = {93 sign: async (): Promise<SignedCommit> => {94 return signedCommit;95 },96 };97 spyOn(signer, 'sign').and.callThrough();98 const returnValue = await commit.sign(signer as any);99 expect(signer.sign).toHaveBeenCalled();100 expect(returnValue).toEqual(signedCommit);101 });102 });...

Full Screen

Full Screen

parse.d.ts

Source:parse.d.ts Github

copy

Full Screen

1/**2 * @license3 * Copyright Google LLC All Rights Reserved.4 *5 * Use of this source code is governed by an MIT-style license that can be6 * found in the LICENSE file at https://angular.io/license7 */8/// <amd-module name="@angular/dev-infra-private/commit-message/parse" />9/// <reference types="node" />10import { Commit as ParsedCommit } from 'conventional-commits-parser';11/** A parsed commit, containing the information needed to validate the commit. */12export interface Commit {13 /** The full raw text of the commit. */14 fullText: string;15 /** The header line of the commit, will be used in the changelog entries. */16 header: string;17 /** The full body of the commit, not including the footer. */18 body: string;19 /** The footer of the commit, containing issue references and note sections. */20 footer: string;21 /** A list of the references to other issues made throughout the commit message. */22 references: ParsedCommit.Reference[];23 /** The type of the commit message. */24 type: string;25 /** The scope of the commit message. */26 scope: string;27 /** The npm scope of the commit message. */28 npmScope: string;29 /** The subject of the commit message. */30 subject: string;31 /** A list of breaking change notes in the commit message. */32 breakingChanges: ParsedCommit.Note[];33 /** A list of deprecation notes in the commit message. */34 deprecations: ParsedCommit.Note[];35 /** Whether the commit is a fixup commit. */36 isFixup: boolean;37 /** Whether the commit is a squash commit. */38 isSquash: boolean;39 /** Whether the commit is a revert commit. */40 isRevert: boolean;41}42/** A parsed commit which originated from a Git Log entry */43export interface CommitFromGitLog extends Commit {44 author: string;45 hash: string;46 shortHash: string;47}48/**49 * A list of tuples expressing the fields to extract from each commit log entry. The tuple contains50 * two values, the first is the key for the property and the second is the template shortcut for the51 * git log command.52 */53declare const commitFields: {54 hash: string;55 shortHash: string;56 author: string;57};58/** The additional fields to be included in commit log entries for parsing. */59export declare type CommitFields = typeof commitFields;60/** The commit fields described as git log format entries for parsing. */61export declare const commitFieldsAsFormat: (fields: CommitFields) => string;62/**63 * The git log format template to create git log entries for parsing.64 *65 * The conventional commits parser expects to parse the standard git log raw body (%B) into its66 * component parts. Additionally it will parse additional fields with keys defined by67 * `-{key name}-` separated by new lines.68 * */69export declare const gitLogFormatForParsing: string;70/** Parse a commit message into its composite parts. */71export declare const parseCommitMessage: (fullText: string) => Commit;72/** Parse a commit message from a git log entry into its composite parts. */73export declare const parseCommitFromGitLog: (fullText: Buffer) => CommitFromGitLog;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var argosyPatterns = require('argosy-patterns')3var service = argosy()4service.accept({5 commitFields: commitFields({6 })7})8service.on('error', console.error)9service.pipe(argosy()).pipe(service)10service.on('argosy/ready', function () {11 var client = service.client()12 client({13 commitFields: {14 }15 }, function (err, result) {16 console.log(result)17 })18})

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var argosyPatterns = require('argosy-patterns')3var argosyCommitFields = require('argosy-commit-fields')4var argosyPipeline = require('argosy-pipeline')5var service = argosy()6service.use(argosyPatterns())7service.use(argosyCommitFields())8service.use(argosyPipeline())9service.accept({commitFields: '*'}, function (request, callback) {10 console.log(request)11 callback(null, {success: true})12})13service.listen(8000)14var argosy = require('argosy')15var argosyPatterns = require('argosy-patterns')16var argosyCommitFields = require('argosy-commit-fields')17var argosyPipeline = require('argosy-pipeline')18var service = argosy()19service.use(argosyPatterns())20service.use(argosyCommitFields())21service.use(argosyPipeline())22service.connect(8000)23service.commitFields({commitFields: true}, function (err, response) {24 console.log(err, response)25})

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')()2var commitFields = require('argosy-patterns/commit-fields')3argosy.accept(commitFields({4 fields: {5 }6}))7argosy.pipe(argosy).pipe(argosy)8var argosy = require('argosy')()9var commitFields = require('argosy-patterns/commit-fields')10argosy.accept(commitFields({11 fields: {12 }13}))14argosy.pipe(argosy).pipe(argosy)15var argosy = require('argosy')()16var commitFields = require('argosy-patterns/commit-fields')17argosy.accept(commitFields({18 fields: {19 }20}))21argosy.pipe(argosy).pipe(argosy)22var argosy = require('argosy')()23var commitFields = require('argosy-patterns/commit-fields')24argosy.accept(commitFields({25 fields: {26 }27}))28argosy.pipe(argosy).pipe(argosy)29var argosy = require('argosy')()30var commitFields = require('argosy-patterns/commit-fields')31argosy.accept(commitFields({32 fields: {33 }34}))35argosy.pipe(argosy).pipe(argosy)36var argosy = require('argosy')()37var commitFields = require('argosy-patterns/commit-fields')38argosy.accept(commitFields({39 fields: {40 }41}))

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var commitFields = require('./commit-fields')3var service = argosy()4service.use(commitFields())5service.accept({ commitFields: true }).process(function (msg, cb) {6 console.log('commitFields called with', msg)7 cb(null, { ok: true })8})9service.listen(8000)10var argosy = require('argosy')11var commitFields = require('argosy/modules/commit-fields')12var service = argosy()13service.use(commitFields())14service.accept({ commitFields: true }).process(function (msg, cb) {15 console.log('commitFields called with', msg)16 cb(null, { ok: true })17})18service.listen(8000)19var argosy = require('argosy')20var commitFields = require('./commit-fields')21var service = argosy()22service.use(commitFields())23service.accept({ commitFields: true }).process(function (msg, cb) {24 console.log('commitFields called with', msg)25 cb(null, { ok: true })26})27service.listen(8000)28var argosy = require('argosy')29var commitFields = require('./commit-fields')30var service = argosy()31service.use(commitFields())32service.accept({ commitFields: true }).process(function (msg, cb) {33 console.log('commitFields called with', msg)34 cb(null, { ok: true })35})36service.listen(8000)37var argosy = require('argosy')38var commitFields = require('./commit-fields')39var service = argosy()40service.use(commitFields())41service.accept({ commitFields: true }).process(function (msg, cb) {42 console.log('commitFields called with', msg)43 cb(null, { ok: true })44})45service.listen(8000)

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var pattern = require('argosy-pattern');3var service = argosy();4var commitFields = pattern({5 CommitFields: pattern.object({6 })7});8var commitRecord = pattern({9 CommitRecord: pattern.object({10 })11});12var deleteRecord = pattern({13 DeleteRecord: pattern.object({14 })15});16var getRecord = pattern({17 GetRecord: pattern.object({18 })19});20var getRecords = pattern({21 GetRecords: pattern.object({22 })23});24var getRecordsByCategory = pattern({

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy'),2 client = argosy(),3 service = client.wrap({4 });5service.commitFields('recordId', {6}).then(function (response) {7 console.log(response);8});9var argosy = require('argosy'),10 client = argosy(),11 service = client.wrap({12 });13service.commitFields('recordId', {14}).then(function (response) {15 console.log(response);16});17var argosy = require('argosy'),18 client = argosy(),19 service = client.wrap({20 });21service.commitFields('recordId', {22}).then(function (response) {23 console.log(response);24});25var argosy = require('argosy'),26 client = argosy(),27 service = client.wrap({28 });29service.commitFields('recordId', {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful