diff --git a/src/libs/ui-utils/package.json b/src/libs/ui-utils/package.json index c098259ef5..63666735b9 100644 --- a/src/libs/ui-utils/package.json +++ b/src/libs/ui-utils/package.json @@ -1,5 +1,5 @@ { "name": "@cowprotocol/ui-utils", - "version": "0.0.1", + "version": "0.0.3", "type": "commonjs" } diff --git a/src/libs/widget-lib/README.md b/src/libs/widget-lib/README.md index d91eb66da1..521a7982f5 100644 --- a/src/libs/widget-lib/README.md +++ b/src/libs/widget-lib/README.md @@ -52,10 +52,9 @@ nx test widget-lib # Build the library nx build widget-lib -cp src/libs/widget-lib/README.md dist/libs/widget-lib # automate # Publish to NPM -npm publish --access=public ./dist/libs/widget-lib +nx publish widget-lib --ver 0.0.7 --tag latest ``` ## Running unit tests diff --git a/src/libs/widget-lib/package.json b/src/libs/widget-lib/package.json index b590c05d83..4c63ac8c32 100644 --- a/src/libs/widget-lib/package.json +++ b/src/libs/widget-lib/package.json @@ -1,6 +1,6 @@ { "name": "@cowprotocol/widget-lib", - "version": "0.0.2", + "version": "0.0.5", "type": "commonjs", "description": "CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your website.", "main": "index.js", diff --git a/src/libs/widget-lib/project.json b/src/libs/widget-lib/project.json index c82caac0d2..cbc42d9833 100644 --- a/src/libs/widget-lib/project.json +++ b/src/libs/widget-lib/project.json @@ -12,12 +12,6 @@ "outputPath": "dist/libs/widget-lib" } }, - "docs": { - "executor": "nx:run-commands", - "options": { - "command": "cp src/libs/widget-lib/README.md dist/libs/widget-lib" - } - }, "publish": { "command": "node tools/scripts/publish.mjs widget-lib {args.ver} {args.tag}", "dependsOn": ["build"] diff --git a/tools/scripts/publish.mjs b/tools/scripts/publish.mjs index e82a097be2..a6214556eb 100644 --- a/tools/scripts/publish.mjs +++ b/tools/scripts/publish.mjs @@ -7,11 +7,12 @@ * You might need to authenticate with NPM before running this script. */ -import { execSync } from 'child_process' -import { readFileSync, writeFileSync } from 'fs' +import devkit from '@nx/devkit' import chalk from 'chalk' -import devkit from '@nx/devkit' +import { execSync } from 'child_process' +import { readFileSync, writeFileSync } from 'fs' +import path from 'path' const { readCachedProjectGraph } = devkit function invariant(condition, message) { @@ -23,7 +24,7 @@ function invariant(condition, message) { // Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag} // Default "tag" to "next" so we won't publish the "latest" tag by accident. -const [, , name, version, tag = 'next'] = process.argv +const [, , name, version, tag] = process.argv // A simple SemVer validation to validate the version const validVersion = /^\d+\.\d+\.\d+(-\w+\.\d+)?/ @@ -43,6 +44,9 @@ invariant( `Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?` ) +const rootLib = path.dirname(project.data.sourceRoot) +const copyReadmeCommand = `cp ${rootLib}/README.md ${outputPath}` +console.log(chalk.bold.greenBright(copyReadmeCommand)) process.chdir(outputPath) // Updating the version in "package.json" before publishing @@ -55,4 +59,7 @@ try { } // Execute "npm publish" to publish -execSync(`npm publish --access public --tag ${tag}`) +const publishCommand = `npm publish --access public --tag ${tag === 'undefined' ? 'next' : tag}` +console.log(chalk.bold.greenBright(publishCommand)) +execSync(publishCommand) +console.log('Published successfully 🎉')