Skip to content

Commit

Permalink
Merge pull request #4 from primno/dev
Browse files Browse the repository at this point in the history
v0.7.0-beta.0
  • Loading branch information
xaviermonin authored Apr 12, 2023
2 parents c9e39ab + 774c612 commit 39565f5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 22 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@primno/cli",
"version": "0.6.2-beta.0",
"version": "0.7.0-beta.0",
"description": "Command-line interface tool for initializing, building, and deploying Primno projects",
"main": "dist/index.mjs",
"files": [
Expand Down Expand Up @@ -63,7 +63,7 @@
"@types/rollup__plugin-virtual": "^2.0.1"
},
"peerDependencies": {
"@primno/core": ">= 0.6.0-beta.0 < 0.7.0-beta.0"
"@primno/core": ">= 0.7.0-beta.0 < 1.0.0-beta.0"
},
"publishConfig": {
"access": "public",
Expand Down
15 changes: 11 additions & 4 deletions src/core/d365/repository/web-resource-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { WebResource } from "../model/web-resource";
export class WebResourceRepository {
public constructor(private client: DataverseClient) {}

public async createOrUpdate(webResource: WebResource): Promise<string> {
/**
* Create or update a web resource.
* @param webResource Web resource to create or update.
* @returns Web resource id or undefined if the web resource does not need to be updated.
*/
public async createOrUpdate(webResource: WebResource): Promise<string | undefined> {
try {
const existingWR = await this.findByName(webResource.name);

Expand All @@ -13,9 +18,11 @@ export class WebResourceRepository {
return result.webresourceid as string;
}
else {
webResource.webresourceid = existingWR.webresourceid;
await this.update(webResource);
return webResource.webresourceid as string;
if (webResource.content !== existingWR.content) {
webResource.webresourceid = existingWR.webresourceid;
await this.update(webResource);
return webResource.webresourceid as string;
}
}
}
catch(except: any) {
Expand Down
22 changes: 14 additions & 8 deletions src/core/deployer/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export abstract class Deployer<TOptions extends DeployerOptions> {
}
}

public async deploy(): Promise<string> {
/**
* Deploy the JS web resource.
* @returns Web resource id or undefined if the web resource does not need to be updated.
*/
public async deploy(): Promise<string | undefined> {
try {
const client = getClient(this.config.environment.connectionString, this.config.deviceCodeCallback);

Expand All @@ -57,13 +61,15 @@ export abstract class Deployer<TOptions extends DeployerOptions> {
solutionid: solution.solutionid
});

await solutionRepository.addSolutionComponent({
ComponentId: webResourceId,
ComponentType: SolutionComponentType.WebResource,
DoNotIncludeSubcomponents: false,
AddRequiredComponents: false,
SolutionUniqueName: this.config.solutionUniqueName
});
if (webResourceId != null) {
await solutionRepository.addSolutionComponent({
ComponentId: webResourceId,
ComponentType: SolutionComponentType.WebResource,
DoNotIncludeSubcomponents: false,
AddRequiredComponents: false,
SolutionUniqueName: this.config.solutionUniqueName
});
}

return webResourceId;
}
Expand Down
7 changes: 6 additions & 1 deletion src/core/entry-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ export class EntryPoint {
);
}

public async deploy(options: EntryPointDeployOptions): Promise<string> {
/**
* Deploy the entry point to the environment.
* @param options Deployment options.
* @returns Id of the web resource or undefined if the web resource don't need to be updated.
*/
public async deploy(options: EntryPointDeployOptions): Promise<string | undefined> {
const { environment, deviceCodeCallback } = options;

const deployCfg = this.config.deploy;
Expand Down
9 changes: 8 additions & 1 deletion src/core/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ export class Workspace {
open(url);
}
}).then((webResourceId) => {
webResourcesId.push(webResourceId);
if (webResourceId != null) {
webResourcesId.push(webResourceId);
}
observer.complete();
}).catch(err => observer.error(err));
})
Expand All @@ -143,6 +145,11 @@ export class Workspace {
.newAction({
title: "Publish",
action: () => new Observable<string>(observer => {
if (webResourcesId.length == 0) {
observer.complete();
return;
}

const publisher = new Publisher({
webResourcesId,
environment: this.environment as Environment,
Expand Down

0 comments on commit 39565f5

Please sign in to comment.