diff --git a/package-lock.json b/package-lock.json index 2a2b9af..bbf4176 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@primno/cli", - "version": "0.6.2-beta.0", + "version": "0.7.0-beta.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@primno/cli", - "version": "0.6.2-beta.0", + "version": "0.7.0-beta.0", "license": "MIT", "dependencies": { "@babel/core": "^7.21.4", @@ -53,7 +53,7 @@ "npm": ">=7" }, "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" } }, "node_modules/@ampproject/remapping": { @@ -1682,9 +1682,9 @@ } }, "node_modules/@primno/core": { - "version": "0.6.0-beta.1", - "resolved": "https://registry.npmjs.org/@primno/core/-/core-0.6.0-beta.1.tgz", - "integrity": "sha512-MYny+DUz23MEkD3I29IRKetUv6VyZPV8AOiGH7MFXFU3u++urkRLv4/Z8dpPQ6Jwnr6UXm2QP78SMHtVhr5Vfw==", + "version": "0.7.0-beta.0", + "resolved": "https://registry.npmjs.org/@primno/core/-/core-0.7.0-beta.0.tgz", + "integrity": "sha512-CQG4W5i7d5wwiiKCOPTo8Ghg+NzgB16hF/sb1LIwxTiPxvD346GbtFIASJ+x/qGLGrcnxbVrza68GlkStWS0fw==", "peer": true, "engines": { "node": ">=16", diff --git a/package.json b/package.json index 1185c6b..3e5cd7e 100644 --- a/package.json +++ b/package.json @@ -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": [ @@ -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", diff --git a/src/core/d365/repository/web-resource-repository.ts b/src/core/d365/repository/web-resource-repository.ts index 3eeed31..5f2c474 100644 --- a/src/core/d365/repository/web-resource-repository.ts +++ b/src/core/d365/repository/web-resource-repository.ts @@ -4,7 +4,12 @@ import { WebResource } from "../model/web-resource"; export class WebResourceRepository { public constructor(private client: DataverseClient) {} - public async createOrUpdate(webResource: WebResource): Promise { + /** + * 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 { try { const existingWR = await this.findByName(webResource.name); @@ -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) { diff --git a/src/core/deployer/deployer.ts b/src/core/deployer/deployer.ts index d227273..eed7fb4 100644 --- a/src/core/deployer/deployer.ts +++ b/src/core/deployer/deployer.ts @@ -30,7 +30,11 @@ export abstract class Deployer { } } - public async deploy(): Promise { + /** + * 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 { try { const client = getClient(this.config.environment.connectionString, this.config.deviceCodeCallback); @@ -57,13 +61,15 @@ export abstract class Deployer { 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; } diff --git a/src/core/entry-point.ts b/src/core/entry-point.ts index af38dd6..4d8d2e2 100644 --- a/src/core/entry-point.ts +++ b/src/core/entry-point.ts @@ -113,7 +113,12 @@ export class EntryPoint { ); } - public async deploy(options: EntryPointDeployOptions): Promise { + /** + * 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 { const { environment, deviceCodeCallback } = options; const deployCfg = this.config.deploy; diff --git a/src/core/workspace.ts b/src/core/workspace.ts index 22844e8..8d10de2 100644 --- a/src/core/workspace.ts +++ b/src/core/workspace.ts @@ -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)); }) @@ -143,6 +145,11 @@ export class Workspace { .newAction({ title: "Publish", action: () => new Observable(observer => { + if (webResourcesId.length == 0) { + observer.complete(); + return; + } + const publisher = new Publisher({ webResourcesId, environment: this.environment as Environment,