semver icon indicating copy to clipboard operation
semver copied to clipboard

Any way get current version in package executor of web:lib?

Open harwee opened this issue 4 years ago • 6 comments

I am trying to get the current version of the library to use it in the outputPath path of package executor. Is there a way to get the version in workspace.json to do something like

"package": {
  "executor": "@nrwl/web:package",
  "options": {
    "project": "package.json",
    "outputPath": "dist/libs/element-base/{version}",
    "entryFile": "libs/element-base/src/index.ts",
    "tsConfig": "libs/element-base/tsconfig.lib.json"
  }
}

harwee avatar Feb 22 '21 21:02 harwee

Hi @harwee, actually there is no way to achieve this and we're not planning to add this feature right now as we're focusing on something else, but if this is needed by some other people we can plan it. I leave it open for now.

edbzn avatar Feb 26 '21 08:02 edbzn

Sounds like this can be solved using postTargets option that we are planning to add here #167

yjaaidi avatar Apr 29 '21 07:04 yjaaidi

I want to bump that issue. postTargets are nice, but sometimes you want to retrieve version without creating a new release. I feel like this should be possible. The implementation details are open for discussion, but I feel like programmatic solution would be great start (since I assume it already exists internally). Something like:

import { getProjectVersion } from '@jscutlery/semver'

async function foo() {
  console.log(await getProjectVersion('my-project-name'));
}

would solve many problems for people who need something more "custom".

Bielik20 avatar Feb 07 '22 14:02 Bielik20

I want to bump that issue. postTargets are nice, but sometimes you want to retrieve version without creating a new release. I feel like this should be possible. The implementation details are open for discussion, but I feel like programmatic solution would be great start (since I assume it already exists internally). Something like:

import { getProjectVersion } from '@jscutlery/semver'

async function foo() {
  console.log(await getProjectVersion('my-project-name'));
}

would solve many problems for people who need something more "custom".

This would be very useful, as I want to write information into a source file to include in the release. I want the tag version that would be used, to be added to a version.ts file per project/library, so I can export that in my code and then use it in UIs and other places.

Chowarmaan avatar Jun 14 '22 20:06 Chowarmaan

Hi, are there any news about this argument? For now, I've prepared a little script that uses git-describe to write a json file into each application that needs to access the tag version.

const { gitDescribeSync } = require('git-describe')
const { writeFileSync } = require('fs')

const APPS_FOLDER = './apps/'
const APPS_VERSION = ['main-app', 'secondary-app']

function recordVersions() {
  APPS_VERSION.forEach((app) => {
    const appFolder = APPS_FOLDER + app
    recordVersion(appFolder, app)
  })
}

function recordVersion(appFolder, appName) {
  const gitInfo = gitDescribeSync({ match: `${appName}*` })
  const versionInfoJson = JSON.stringify(gitInfo, null, 2)

  writeFileSync(appFolder + '/git-version.json', versionInfoJson)
}

recordVersions()

There are several problems about this workaround:

  • the script must be called by hand each time an application has been released
  • the git-version.json files must be committed before pushing the updates

Is there a way to resolve these problems?

Thank you

nicolomanni avatar Jul 28 '22 12:07 nicolomanni

Is there any updates on this, i would like to access the version so i can use that in other executors.

kodeine avatar Oct 17 '22 05:10 kodeine