Skip to content

Port changes for release v1.0.19 and Changelog #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 56 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ version: 2.1
orbs:
win: circleci/windows@2.2.0
sfchangecase: salesforce/change-case-management@3
slack: circleci/slack@3.4.2

parameters:
publish:
type: boolean
default: false
publish-type:
type: string
default: patch

_refs:
defaults: &defaults
Expand Down Expand Up @@ -42,7 +51,7 @@ _refs:
name: Upload coverage to codecov.io
command: |
./node_modules/nyc/bin/nyc.js report --reporter=lcov
curl -s https://codecov.io/bash | bash -s -- -f ./test-results/coverage/lcov.info
node ./scripts/uploadCodeCoverage.js
gus-prepare-environment-variables: &gus-prepare-environment-variables
name: 'Prepare environment variables for GUS Change Case Management'
command: |
Expand Down Expand Up @@ -107,9 +116,13 @@ jobs:
shell: bash.exe
- store_test_results:
path: test-results
release:
publish:
<<: *defaults
steps:
- slack/notify:
channel: 'pdt_releases'
color: '#FFDEAD'
message: 'Starting Publish for SDR Library'
- add_ssh_keys: *ssh-config
- checkout
- restore_cache: *restore_cache
Expand All @@ -127,10 +140,12 @@ jobs:
- run:
name: Bump package version
command: |
yarn version --patch --no-git-tag-version
yarn version --<< pipeline.parameters.publish-type >> --no-git-tag-version
git add package.json
export RELEASE_TAG="$(node -pe "require('./package.json').version")"
git commit -m "[skip ci] Updated version $RELEASE_TAG"
echo "export RELEASE_VERSION=$RELEASE_TAG" >> $BASH_ENV
source $BASH_ENV
git commit -m "Updated version $RELEASE_TAG"
- run:
name: Set .npmrc
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
Expand All @@ -139,16 +154,24 @@ jobs:
- run:
name: Tag the release and push to repo
command: |
export RELEASE_TAG="$(node -pe "require('./package.json').version")"
git tag v${RELEASE_TAG}
git tag v${RELEASE_VERSION}
git push --tags
- sfchangecase/update:
location: REPO_LOCATION
release: GUS_RELEASE
- slack/notify:
channel: 'pdt_releases'
color: '#9bcd9b'
message: 'SDR Library v${RELEASE_VERSION} has been published to npm'
- slack/status:
channel: 'pdt_releases'
fail_only: true

workflows:
version: 2
'deploy-and-retrieve':
version: 2.1

commit-workflow:
unless: << pipeline.parameters.publish >>
jobs:
- node-latest
- node-12
Expand All @@ -160,13 +183,28 @@ workflows:
branches:
ignore: /.*/
- run-win-tests
- release:
filters:
branches:
only:
- main
requires:
- node-latest
- node-12
- node-10
- run-win-tests

publish-workflow:
when: << pipeline.parameters.publish >>
jobs:
- slack/approval-notification:
message: Pending Approval for Publish of SDRL (Source Deploy Retrieve Library)
channel: 'pdt_releases'
color: '#0E1111'
- node-latest
- node-12
- node-10
- run-win-tests
- hold: # Requires manual approval in Circle Ci
type: approval
- publish:
filters:
branches:
only:
- main
requires:
- node-latest
- node-12
- node-10
- run-win-tests
- hold
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Publish Local Dev Server",
"command": "./script/publish-workflow.sh",
"type": "shell",
"args": ["${input:circleCiId}", "${input:publishType}"]
}
],
"inputs": [
{
"id": "circleCiId",
"type": "promptString",
"description": "CircleCi Token"
},
{
"id": "publishType",
"type": "pickString",
"description": "Type of version to publish",
"options": ["minor", "patch", "major"],
"default": "patch"
}
]
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# 1.0.19 - August 13, 2020

## Added

- Add component resolution for files in metadata format ([PR #94](https://github.com/forcedotcom/source-deploy-retrieve/pull/94))

- Add recomposition for CustomObjects ([PR #95](https://github.com/forcedotcom/source-deploy-retrieve/pull/95))

## Fixed

- Fixed content file not being included during source conversion for NetworkBranding components ([PR #106](https://github.com/forcedotcom/source-deploy-retrieve/pull/106))

# 1.0.18 - August 6, 2020

## Added

- Add readFile to TreeContainer ([PR #96](https://github.com/forcedotcom/source-deploy-retrieve/pull/96))

## Fixed

- Replaced module `gitignore-parser` for parsing forceignore files with `ignore` ([PR #98](https://github.com/forcedotcom/source-deploy-retrieve/pull/98))

# 1.0.17 - July 28, 2020

## Added
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
"node": ">=10.17.0"
},
"dependencies": {
"@salesforce/core": "2.5.1",
"@salesforce/core": "2.9.0",
"archiver": "4.0.1",
"fast-xml-parser": "^3.17.4",
"ignore": "^5.1.8",
"xmldom-sfdx-encoding": "^0.1.29"
},
"devDependencies": {
"@salesforce/ts-sinon": "^1.1.2",
"@salesforce/ts-types": "^1.4.2",
"@types/archiver": "^3.1.0",
"@types/chai": "^4",
"@types/mocha": "^5",
Expand Down Expand Up @@ -67,7 +69,7 @@
"local:install": "./scripts/localInstall.js install",
"local:link": "./scripts/localInstall.js link",
"local:unlink": "./scripts/localInstall.js unlink",
"test": "shx rm -rf ./test-results && nyc mocha && node ./scripts/verifyTestArtifacts",
"test": "shx rm -rf ./test-results && nyc mocha",
"update:registry": "node ./scripts/metadata-registry/update.js"
},
"husky": {
Expand Down
15 changes: 15 additions & 0 deletions scripts/publish-workflow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# For publishing a different version, see the format below for adding a publish-type
# parameter:
# "publish-type": "minor"

CircleCIToken=$1
PublishType=$2
curl -v -u ${CircleCIToken}: -X POST --header "Content-Type: application/json" -d '{
"branch": "main",
"parameters": {
"publish": true,
"publish-type": "'"${PublishType}"'"
}
}' https://circleci.com/api/v2/project/gh/forcedotcom/source-deploy-retrieve/pipeline
32 changes: 32 additions & 0 deletions scripts/uploadCodeCoverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const { execSilent } = require('./util');

/**
* Script for publishing code coverage results to Codecov.io. Intended to run
* during a CircleCI job.
*
* Not using path.join for the path to coverage report because in the Windows job,
* this script runs with bash.exe to allow running the codecov.io publish script.
* Hence using a Windows formatted path will confuse the process.
*/

const MAX_ATTEMPTS = 3;

let attempts = 0;

do {
try {
const result = execSilent('curl -s https://codecov.io/bash | bash -s -- -f test-results/coverage/lcov.info');
console.log(result.stdout);
break;
} catch (e) {
attempts += 1;
let message = `Failed to publish coverage results on attempt ${attempts}`;
if (attempts < MAX_ATTEMPTS) {
message += ' - trying again...';
}
console.log(message);
console.log(e.message);
}
} while (attempts < MAX_ATTEMPTS);
12 changes: 0 additions & 12 deletions scripts/verifyTestArtifacts.js

This file was deleted.

79 changes: 79 additions & 0 deletions src/convert/convertTransaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { WriterFormat } from './types';
import { DecomposedMetadataTransformer } from './transformers/decomposedMetadataTransformer';
import { SourceComponent } from '../metadata-registry';

export type ConvertTransactionState = {
recompose: {
[fullName: string]: {
/**
* Parent component that children are rolled up into
*/
component: SourceComponent;
/**
* Children to be rolled up into the parent file
*/
children: SourceComponent[];
};
};
};

/**
* Manages a "global" state over the course of a single metadata conversion call.
*/
export class ConvertTransaction {
public readonly state: ConvertTransactionState = { recompose: {} };
private readonly finalizers = new Map<string, ConvertTransactionFinalizer>();

public addFinalizer(finalizerCtor: FinalizerConstructor): void {
if (!this.finalizers.has(finalizerCtor.name)) {
this.finalizers.set(finalizerCtor.name, new finalizerCtor());
}
}

/**
* Call right before the end of a conversion pipeline to execute logic with
* the transaction state.
*/
public *executeFinalizers(): IterableIterator<WriterFormat | WriterFormat[]> {
for (const finalizer of this.finalizers.values()) {
yield finalizer.finalize(this.state);
}
}
}

/**
* Logic to execute at the end of a convert transaction
*/
export interface ConvertTransactionFinalizer {
finalize(state: ConvertTransactionState): WriterFormat | WriterFormat[];
}

export interface FinalizerConstructor {
new (): ConvertTransactionFinalizer;
}

export class RecompositionFinalizer implements ConvertTransactionFinalizer {
public finalize(state: ConvertTransactionState): WriterFormat[] {
const writerData: WriterFormat[] = [];

for (const parentName of Object.keys(state.recompose)) {
const parentComponent = state.recompose[parentName].component;
// only recompose children stored in transaction state
const children = state.recompose[parentName].children;
const recomposedXmlObj = DecomposedMetadataTransformer.recompose(children);
const writerFormat = DecomposedMetadataTransformer.createWriterFormat(
parentComponent,
recomposedXmlObj
);
writerData.push(writerFormat);
}

return writerData;
}
}
8 changes: 8 additions & 0 deletions src/convert/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
export { MetadataConverter } from './metadataConverter';
export {
ConvertResult,
ConvertOutputConfig,
SfdxFileFormat,
WriteInfo,
WriterFormat,
MetadataTransformer,
} from './types';
4 changes: 2 additions & 2 deletions src/convert/metadataConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { SfdxFileFormat, ConvertOutputConfig, ConvertResult } from '../types';
import { SfdxFileFormat, ConvertOutputConfig, ConvertResult } from './types';
import { ManifestGenerator, RegistryAccess, SourceComponent } from '../metadata-registry';
import { promises } from 'fs';
import { join } from 'path';
Expand Down Expand Up @@ -64,7 +64,7 @@ export class MetadataConverter {

const conversionPipeline = pipeline(
new ComponentReader(components),
new ComponentConverter(targetFormat, this.registryAccess),
new ComponentConverter(targetFormat, this.registryAccess.registry),
writer
);
tasks.push(conversionPipeline);
Expand Down
Loading