I've just setup Nerdbank.GitVersionning in my project and I have the same setup as Dapper
Here is my version.json
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.1.0-alpha.{height}",
"assemblyVersion": "0.1.0.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/tags/v\\d+\\.\\d+"
],
"nugetPackageVersion": {
"semVer": 2
},
"cloudBuild": {
"buildNumber": {
"enabled": true,
"setVersionVariables": true
}
}
}
If I do nbgv get-version:
Version: 0.1.0.1
AssemblyVersion: 0.1.0.0
AssemblyInformationalVersion: 0.1.0-alpha.1+021de4e5ee
NuGet package Version: 0.1.0-alpha.1
NPM package Version: 0.1.0-alpha.1
Here is Dapper's version.json
{
"version": "1.50.8-alpha.{height}",
"assemblyVersion": "1.50.0.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/tags/v\\d+\\.\\d+"
],
"nugetPackageVersion": {
"semVer": 2
},
"cloudBuild": {
"buildNumber": {
"enabled": true,
"setVersionVariables": true
}
}
}
If I do nbgv get-version:
Version: 1.50.8.23
AssemblyVersion: 1.50.0.0
AssemblyInformationalVersion: 1.50.8-alpha.23+e7020b2bde
NuGet package Version: 1.50.8-alpha.23.e7020b2bde
NPM package Version: 1.50.8-alpha.23.e7020b2bde
Any idea on why there is a difference on Nuget & NPM package version?
I suspect you are in the master branch in your repo, and not in master in the Dapper repo. That's why the git commit ids are being dropped from the NuGet / NPM package version strings. According to https://github.com/AArnott/Nerdbank.GitVersioning/blob/master/doc/versionJson.md:
The publicReleaseRefSpec field causes builds out of certain branches or tags to automatically drop the -gabc123 git commit ID suffix from the version, making it convenient to build releases out of these refs with a friendly version number that assumes linear versioning.
Related
I created 3 package versions - 0.1.0.1, 0.1.0.2, 0.1.0.3 of 2nd generation managed package.
I promoted 0.1.0.3 to release
I created versions 0.1.0.4 - 0.1.0.6 with --skipancestorcheck
I made following update in sfdx-project file:
I specified ancestorId in sfdx-project file as id (04t......) of released version 0.1.0.3
I set "versionName" to "ver 0.2" from "ver 0.1"
I set "versionNumber" to "0.2.0.NEXT" from "0.1.0.NEXT"
I ran command sfdx force:package:beta:version:create --package "Test App" --installationkey "XXX" --definitionfile config/project-scratch-def.json --wait 10 -c"
I got error
"ERROR running force:package:version:create: An unexpected error occurred. Please include this ErrorId if you contact support: 636537585-177978 (-693775129)"
Salesforce Support found that ErrorId is related to "java.lang.RuntimeException: Failed to retrieve Second Generation Package Version info of ancestor 05i3z000000fyk0AAA."
05i3z000000fyk0AAA is Id of Package2Version record of version 0.1.0.3 in my DevHub org
My expectation is that new beta version of package will be created but I got error.
Did you have something similar?
I am now stuck, because I can not delete released version of 2nd generation package and I can not create new one. Do you have any idea how to get out of this?
I tried ancestorVersion : HIGHEST and all possible values for ancestorId, ancestorVersion but nothing helped.
My latest sfdx-project file is
{
"packageDirectories": [
{
"path": "force-app",
"default": true,
"package": "Test App Core",
"versionName": "ver 0.2",
"versionNumber": "0.2.0.NEXT",
"ancestorId":"04t..........YAAQ"
}
],
"name": "test-salesforce-core",
"namespace": "zenoo_app",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "55.0",
"packageAliases": {
"Test App Core": "0Ho3........CAA",
"Test App Core#0.1.0-1": "04t..............OAAQ",
"Test App Core#0.1.0-2": "04t..............TAAQ",
"Test App Core#0.1.0-3": "04t..............YAAQ"
}
}
I am using sfdx-cli version 7.176
I'm currently using create-react-app to bootstrap one of my projects. Basically, I'm trying to set up paths in tsconfig.json by adding these to the default tsconfig.json generated by create-react-app:
"baseUrl": "./src",
"paths": {
"interfaces/*": [
"common/interfaces/*",
],
"components/*": [
"common/components/*",
],
},
However, every time I run yarn start which basically runs react-scripts start, it deletes my changes and generates the default configurations again.
How can I tell create-react-app to use my custom configs?
I was able to do this by using advice from this issue.
Put the configuration options react scripts likes to remove in a separate file (e.g. paths.json) and reference it from tsconfig.json via the extends directive.
paths.json:
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"interfaces/*": [ "common/interfaces/*"],
"components/*": [ "common/components/*"],
}
}
}
tsconfig.json
{
"extends": "./paths.json"
...rest of tsconfig.json
}
Create React App does not currently support baseUrl. However there is a workaround...to setup baseUrl for both webpack and the IDE you have to do the following:
Create a .env file with the following code:
NODE_PATH=./
Create a tsconfig.paths.json file with the following code inside:
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"src/*": ["*"]
}
}
}
Add the following line to tsconfig.json
{
"extends": "./tsconfig.paths.json",
...
}
You can't and I am unsure when you will be able to. I have been trying to use baseUrl and paths so I can avoid relative imports but as you can see they are intentionally removing certain values. The "(yet)" is encouraging but (sigh) who knows when they will officially be supporting it. I recommend subscribing to this github issue to be alerted if/when this changes.
The following changes are being made to your tsconfig.json file:
- compilerOptions.baseUrl must not be set (absolute imports are not supported (yet))
- compilerOptions.paths must not be set (aliased imports are not supported)
If you are using react-scripts 4.0.0 like me then all you need to do is remove the line (around line 160 on my end):
paths: { value: undefined, reason: 'aliased imports are not supported' }
from the file node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
I was able to straight up add my baseUrl and paths config to my tsconfig.json file like so:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"#domain/*": ["../src/domain/*"],
},
}
}
and finally compile and move on with my life.
Per usual, YMMV. Please test your stuff. This is obviously a hack but it worked for me so I'm posting here in case it helps someone.
Here's a patch if you feel like sharing with your team:
diff --git a/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js b/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
index 00139ee..5ccf099 100644
--- a/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
+++ b/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
## -156,7 +156,8 ## function verifyTypeScriptSetup() {
: 'react',
reason: 'to support the new JSX transform in React 17',
},
- paths: { value: undefined, reason: 'aliased imports are not supported' },
+ // Removed this line so I can add paths to my tsconfig file
+ // paths: { value: undefined, reason: 'aliased imports are not supported' },
};
Edit
Per #Bartekus thoughtful suggestion in the comments thread I'm adding information on the package I use when I need to add (possibly) temporary changes like these to an npm package: patch-package
The package essentially provides a way to make changes to a package in a cleaner way. Especially when you consider collaboration it becomes very cumbersome to directly change an npm file and move on. The next time you update that package or even when you start developing in a new machine and run npm install your changes will be lost. Also, if you have teammates working on the same project they would never inherit the changes.
In essence you go through the following steps to patch a package:
# fix a bug in one of your dependencies
vim node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
# run patch-package to create a .patch file
npx patch-package react-scripts
# commit the patch file to share the fix with your team
git add patches/react-scripts+4.0.0.patch
git commit -m "Enable aliased imports in react-scripts"
Next time someone checks out the project and installs it, the patch will be applied automatically due to a post-install script you add during set up:
"scripts": {
+ "postinstall": "patch-package"
}
See up to date instructions in the package's documentation
I had a similar issue to this general problem (CRA overwrites "noEmit": false in my tsconfig.json of a React library I'm working on where I have two separate builds, one for local development, and another to build the production library with typings). Simple solution: use sed in a postbuild script in the package.json. For example: In-place edits with sed on OS X .
{
...
"scripts": {
...
"postbuild": "sed -i '' 's/{THING CRA IS REPLACING}/{WHAT YOU ACTUALLY WANT}/g' tsconfig.json # CRA is too opinionated on this one.",
...
}
...
}
This approach, however, is not cross-platform (unlike how rimraf is the cross-platform alternative to rm -rf).
For me, the problem was with VSCode using an older version of typescript (4.0.3), while the typescript version shipped with the project is (4.1.2).
The following did the trick for me:
Go to the command palette CTRL+Shift+P.
Choose "TypeScript: Select a TypeScript Version...".
Choose "Use workspace Version".
On Botpress (with react-scripts 4.0.3), we use a combination of 2 tricks to use paths without ejecting or patching the code. As Glenn and Microcipcip said, the first step is to extend the tsconfig.json file
tsconfig.path.json
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"~/*": ["src/*"],
"common/*": ["../bp/src/common/*"]
}
}
}
tsconfig.json
{
...
"extends": "./tsconfig.paths.json"
}
Then to make it work in the background, use the package react-app-rewired. It allows to make slight adjustments to the webpack configuration without actually ejecting CRA.
config-overrides.js
module.exports = {
webpack: (config, env) => {
config.resolve.alias['common'] = path.join(__dirname, '../bp/dist/common')
config.resolve.alias['~'] = path.join(__dirname, './src')
}
}
To see the full code, you can check the github repository https://github.com/botpress/botpress/tree/master/packages/ui-admin
For macOS this workaround should work.
package.json
"scripts": {
"start": "osascript -e 'tell app \"Terminal\" to do script \"cd $PATH_TO_REACT_APP && node ./setNoEmitFalse\"' && react-scripts start",
...
},
...
setNoEmitFalse.js
const fs = require('fs');
const { sleep } = require('sleep')
const path = './tsconfig.json'
const run = async () => {
sleep(2)
const tsconfig = fs.readFileSync(path, 'utf-8');
const fixed = tsconfig.replace('"noEmit": true', '"noEmit": false');
fs.writeFileSync(path, fixed)
}
run()
The execution of the javascript file in a separate terminal (osascript) provides the normal output for react-scripts in the original terminal.
Go to node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js and replace
const compilerOptions = {
...
};
by
const compilerOptions = { };
This diagram explains my question ---->
Version Conflict
My product takes a dependency on a node package, which takes a dependency on a certain version of Angular, lets say version #y.
However, my product relies on a different version of Angular - lets say version #x.
I cannot ensure that #x = #y.
What is the best way to avoid such version conflicts?
If your dependency is for e.g. Angular X.Y and your angular version is X, compatibility problems shouldn't arise, but you can use npm shrinkwrap functionality which will allow you to lockdown version of dependencies.
It will generate npm-shrinkwrap.json file.
{
"name": "A",
"version": "1.1.0",
"dependencies": {
"B": {
"version": "1.0.1",
"from": "B#^1.0.0",
"resolved": "https://registry.npmjs.org/B/-/B-1.0.1.tgz",
"dependencies": {
"C": {
"version": "1.0.1",
"from": "org/C#v1.0.1",
"resolved": "git://github.com/org/C.git#5c380ae319fc4efe9e7f2d9c78b0faa588fd99b4"
}
}
}
}
}
You can read more about it here.
I'm using Cakephp and Miles's uploader plugin. I've got the composer plugin installed, and I'm using the latest copy of wamp. Fileinfo extension is enabled in php. when I try to update using composer it doesn't - it just uses a previous version. If I change the json file to force an update to the latest version I get and error message telling me the ext-fileinfo is not present - but it is.............
I need to get the lastest version as I have an error which shows up on my webserver which is running php 5.3 (wamp is using 5.4)
Additional info:-
The main composer.json is :-
{"config":{"vendor-dir":"Vendor"},
"require": {
"mjohnson/uploader": "4.3.*",
"mjohnson/utility": "1.5.*",
"mjohnson/decoda": "*",
"titon/utility": "*",
"cakephp/debug_kit": "2.2.*"
}
}
I'm expecting mjohnson/uploader to update (
a sub set composer.JSON is held in the uploader package :-
{
"name": "mjohnson/uploader",
"type": "cakephp-plugin",
"description": "File uploader and validation plugin for CakePHP.",
"keywords": ["cakephp", "uploader", "plugin", "file", "validation", "attachment"],
"homepage": "http://milesj.me/code/cakephp/uploader",
"license": "MIT",
"authors": [
{
"name": "Miles Johnson",
"homepage": "http://milesj.me"
}
],
"require": {
"php": ">=5.3.3",
"ext-curl": "*",
"ext-mbstring": "*",
"composer/installers": "*",`enter code here`
"mjohnson/transit": ">=1.4"
},
"support": {
"source": "https://github.com/milesj/Uploader"
}
}
and I would also have expected mjohnson/transit to have updated
I had a similar problem with ext-fileinfo and ext-curl on Windows 7. My problem was the path variable causing the wrong php.exe to be executed by composer. If php -m from the command line shows ext-fileinfo is not present that could be your problem too.
When I update my composer to add yii2-solr extension to my project, I encounter with an error like below:
The "yiisoft/yii2-composer" plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example).
The "fxp/composer-asset-plugin" plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example).
PHP Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272
Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272
before that I've ran composer self-updatebut still not work and when I want to run
composer global require "fxp/composer-asset-plugin:1.0.1"
again the above error shown.
This is my composer.json file content:
{
"name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Project Template",
"keywords": ["yii2", "framework", "basic", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"filsh/yii2-oauth2-server": "*",
"johnitvn/yii2-rbac-plus": "*",
"yiisoft/yii2-sphinx": "^2.0",
"yiisoft/yii2-solr": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*"
},
"config": {
"process-timeout": 1800
},
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::postCreateProject"
]
},
"extra": {
"yii\\composer\\Installer::postCreateProject": {
"setPermission": [
{
"runtime": "0777",
"web/assets": "0777",
"yii": "0755"
}
],
"generateCookieValidationKey": [
"config/web.php"
]
},
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
How can I fix this error?
Thanks.
1) Remove old version of Composer Asset Plugin:
composer global remove "fxp/composer-asset-plugin"
2) Install newer version. Recommended version for installation is now (by the moment of writing this) 1.1.1 (see official docs).
composer global require "fxp/composer-asset-plugin:~1.1.1"
I'd even recommend to use:
composer global require "fxp/composer-asset-plugin:*"
3) Run composer install in your project folder. In case of errors, delete vendor folder contents and composer.lock file and run composer install again.
If arogachev's answer doesn't exactly work for you, here is a quick fix.
Manually delete the vendor folder in your global composer installation. The folder to delete for eg. on ubuntu : /home/user/.composer/vendor
Install the newer version of the plugin
composer global require "fxp/composer-asset-plugin:*"
That should be all. You will get all your files back and you can continue
Bower-Asset skip way:
You can require yidas/yii2-composer-bower-skip before yiisoft/yii2 in composer.json file:
"require": {
"php": ">=5.4.0",
"yidas/yii2-composer-bower-skip": "~2.0.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-bootstrap": "*",
...
Then run composer update.
This case is for that you don't need the update for Bower.
See https://github.com/yidas/yii2-composer-bower-skip
Rollback composer to 1.x version - the said plugin does not work (yet) with composer 2.x (as discussed here):
sudo composer self-update --rollback