configure semantic-release to publish pre-release via CLI - semantic-versioning

My goal is configure semantic-release to create tag from the protected branches like this:
npx semantic-release --plugins #semantic-release/commit-analyzer --branches {'name': 'release/super-feature', 'prerelease': true}
I'm expecting that tag 1.0.0-super-feature will be created. However, i'm getting an exception:
[semantic-release] › ✖ EINVALIDBRANCH A branch is invalid in the `branches` configuration.
Each branch in the branches configuration (https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches) must be either a string, a regexp or an object with a name property.
Your configuration for the problematic branch is ``.
[10:03:55 AM] [semantic-release] › ✖ EINVALIDBRANCH A branch is invalid in the `branches` configuration.
Each branch in the branches configuration (https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches) must be either a string, a regexp or an object with a name property.
Your configuration for the problematic branch is ``.
AggregateError:
SemanticReleaseError: A branch is invalid in the `branches` configuration.
at module.exports (/usr/local/lib/node_modules/semantic-release/lib/get-error.js:6:10)
at /usr/local/lib/node_modules/semantic-release/lib/verify.js:36:19
at Array.forEach (<anonymous>)
at module.exports (/usr/local/lib/node_modules/semantic-release/lib/verify.js:32:12)
at async run (/usr/local/lib/node_modules/semantic-release/index.js:54:3)
at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
SemanticReleaseError: A branch is invalid in the `branches` configuration.
at module.exports (/usr/local/lib/node_modules/semantic-release/lib/get-error.js:6:10)
at /usr/local/lib/node_modules/semantic-release/lib/verify.js:36:19
at Array.forEach (<anonymous>)
at module.exports (/usr/local/lib/node_modules/semantic-release/lib/verify.js:32:12)
at async run (/usr/local/lib/node_modules/semantic-release/index.js:54:3)
at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
at module.exports (/usr/local/lib/node_modules/semantic-release/lib/verify.js:41:11)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async run (/usr/local/lib/node_modules/semantic-release/index.js:54:3)
at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5) {
name: 'AggregateError'
}
Could you please help me to understand what is wrong - CLI parameters or my expectations?

Related

Puppeteer incompatible with Vercel serverless functions? (Next 13)

I deployed an API route handler with Next.js 13 that uses Puppeteer. When I call this api route in production, I get this error message in 'Function Logs':
[POST] /api/getLinkedin
00:00:21:62
2023-02-02T00:00:23.103Z 7545c99c-ea8f-41d3-8771-97eb786502cb ERROR Error: Could not find Chromium (rev. 1083080). This can occur if either
1. you did not perform an installation before running the script (e.g. `npm install`) or
2. your cache path is incorrectly configured (which is: /home/sbx_user1051/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
at ChromeLauncher.resolveExecutablePath (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:127:27)
at ChromeLauncher.executablePath (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:205:25)
at ChromeLauncher.launch (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:93:37)
at async handler (/var/task/.next/server/pages/api/getLinkedin.js:27:21)
at async Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:372:9)
at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:488:9)
at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:751:37)
at async Router.execute (/var/task/node_modules/next/dist/server/router.js:253:36)
at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:384:29)
at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:322:20)
2023-02-02T00:00:23.124Z 7545c99c-ea8f-41d3-8771-97eb786502cb ERROR Error: Could not find Chromium (rev. 1083080). This can occur if either
1. you did not perform an installation before running the script (e.g. `npm install`) or
2. your cache path is incorrectly configured (which is: /home/sbx_user1051/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
at ChromeLauncher.resolveExecutablePath (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:127:27)
at ChromeLauncher.executablePath (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:205:25)
at ChromeLauncher.launch (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:93:37)
at async handler (/var/task/.next/server/pages/api/getLinkedin.js:27:21)
at async Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:372:9)
at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:488:9)
at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:751:37)
at async Router.execute (/var/task/node_modules/next/dist/server/router.js:253:36)
at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:384:29)
at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:322:20)
RequestId: 7545c99c-ea8f-41d3-8771-97eb786502cb Error: Runtime exited with error: exit status 1
Runtime.ExitError
I went to the Puppeteer docs and I changed the config file as shown:
const {join} = require('path');
/**
* #type {import("puppeteer").Configuration}
*/
module.exports = {
// Changes the cache location for Puppeteer.
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};
That didn't fix it.

#aws-sdk/client-sts - TypeError: (0 , smithy_client_1.parseRfc3339DateTimeWithOffset) is not a function

I'm facing issue using sts client on lambdas.
The current code was working two days ago.
const {
STSClient,
AssumeRoleCommand,
} = require('#aws-sdk/client-sts')
const stsClient = new STSClient({
region: process.env.REGION || 'eu-west-1',
})
const params = new AssumeRoleCommand({
RoleArn: process.env.MARKETPLACE_RESOLVE_CUSTOMER_ROLE_ARN,
RoleSessionName: `${
process.env.AWS_LAMBDA_FUNCTION_NAME
}-${new Date().getTime()}`,
})
const assumedRoleOutput = await stsClient.send(params)
Now it always throws an exception as follow:
2023-02-08T08:07:18.684Z 1a7dd68d-da00-4b07-935c-2f6bc95f996f ERROR TypeError: (0 , smithy_client_1.parseRfc3339DateTimeWithOffset) is not a function
at deserializeAws_queryCredentials (/opt/nodejs/node_modules/#aws-sdk/client-sts/dist-cjs/protocols/Aws_query.js:860:117)
at deserializeAws_queryAssumeRoleResponse (/opt/nodejs/node_modules/#aws-sdk/client-sts/dist-cjs/protocols/Aws_query.js:756:32)
at deserializeAws_queryAssumeRoleCommand (/opt/nodejs/node_modules/#aws-sdk/client-sts/dist-cjs/protocols/Aws_query.js:119:16)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /opt/nodejs/node_modules/#aws-sdk/client-sts/node_modules/#aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
at async /opt/nodejs/node_modules/#aws-sdk/client-sts/node_modules/#aws-sdk/middleware-signing/dist-cjs/middleware.js:14:20
at async StandardRetryStrategy.retry (/opt/nodejs/node_modules/#aws-sdk/client-sts/node_modules/#aws-sdk/middleware-retry/dist-cjs/StandardRetryStrategy.js:51:46)
at async /opt/nodejs/node_modules/#aws-sdk/client-sts/node_modules/#aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:5:22
at async getMarketplaceResolveCustomerRoleCredentials (/var/task/utils/marketplaceUtils.js:27:29)
at async Object.resolveMarketplaceCustomer (/var/task/utils/marketplaceUtils.js:50:5) {
'$metadata': { attempts: 1, totalRetryDelay: 0 }
I've tried it with the #aws-sdk/client-sts at versions 3.266.0 and 3.224.0
The problem was the incorrect aws-sdk version installed during the creation of the layer.
I use a docker file to install all the dependencies used by my lambdas and was using the command like:
RUN npm i #aws-sdk/client-sts#3.224.0
RUN npm i #aws-sdk/client-marketplace-entitlement-service#3.266.0
So there was inconsistency between sdk versions probably?
So I tried to create the layer without including the aws sdk modules (removed by hand) and it worked (the sdk is included in lambda execution enviroment)
But I faced another error with aws-sdk/client-marketplace-entitlement-service that where fixed some times ago git issue
So I've changed the commands on the Dockerfile to install latest major release I wanted, as follow:
RUN npm i #aws-sdk/client-sts#3
RUN npm i #aws-sdk/client-marketplace-entitlement-service#3
and now it works!

Cannot load json file from repo in GitHub Action with Node

I'm trying to create a GitHub Action which :
browse a folder in the repo where the action is called
load the files that are in this folder as JSON schemas in an ajv instance
validate a file in the same repo against the instance
My problem is:
My Node script works well in a local environment, but shows an error on loading of JSON files :
Error: Cannot find module './GeoJSON_schemas/LineString.json'
Require stack:
- /home/runner/work/_actions/idrissad/jsonschema_validator/v1.0/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at /home/runner/work/_actions/idrissad/jsonschema_validator/v1.0/dist/index.js:8105:19
at /home/runner/work/_actions/idrissad/jsonschema_validator/v1.0/dist/index.js:8118:3
at Object.<anonymous> (/home/runner/work/_actions/idrissad/jsonschema_validator/v1.0/dist/index.js:8121:12)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/runner/work/_actions/idrissad/jsonschema_validator/v1.0/dist/index.js'
]
}
Here is the Action code:
const core = require('#actions/core');
const fs = require('fs');
//const path = require('path');
const schema_path = core.getInput('main_schema_path');
const schemas_dir = core.getInput('additional_schemas_dir');
const data = core.getInput('data_path');
const Ajv = require("ajv");
const addFormats = require("ajv-formats");
const ajv = new Ajv({allErrors: true, strict: false});
addFormats(ajv);
let add_schemas = fs.readdirSync(schemas_dir);
for (let add_schema of add_schemas) {
add_schema_path = schemas_dir + add_schema
ajv.addSchema(require(add_schema_path), add_schema); //THIS REQUIRE IS THE ONE THAT DOESN'T WORK
};
const schema = require(schema_path);
const validate = ajv.compile(schema);
test(require(data_path));
function test(data) {
const valid = validate(data);
if (valid) core.setOutput('validity', "Valid!")
else core.setOutput('validity', "Invalid: " + ajv.errorsText(validate.errors))
};
Link of the GitHub Action repo: (https://github.com/IdrissaD/jsonschema_validator)
Link of the workflow error: (https://github.com/PnX-SI/schema_randonnee/runs/3144851785)
So the JSON file I'm trying to load is not a module (at least I believe so), and locally my script loads it perfectly with the "same" code. The difference is that I build the path with inputs from the yml workflow file.
I don't understand if the script just don't get to the right place, thus doesn't find any file called LineString.json, or if it gets to the right folder but doesn't manage to load the file as it takes it for a module?
I believe it can have something to do with the way I should write the fs.readDirSync in a GitHUb context (comparing to a local one), but I struggle to understand the solution.
Ok I got it, the directory in which the script was run was actually /home/runner/work/schema_randonnee/schema_randonnee/ (visible in the workflow logs of the actions/checkout#v2 run).
So by adding /home/runner/work/schema_randonnee/schema_randonnee/GeoJSON_schemas/ before all my input values (main_schema_path, additional_schemas_dir and data_path), the script managed to reach the files in the workflow repo!
Conclusion
The action checkout#v2 checks out the repository under $GITHUB_WORKSPACE (cf. README) and this env value is defined by default on /home/runner/work/my-repo-name/my-repo-name as visible in this GitHub doc. Without changement on the run of that checkout action, it's the directory to indicate to the GitHub Action you're calling (which is by default running at the same level than /home if I understand well).
Edit:
even better than the previous solution, I should use the generated$GITHUB_WORKSPACE variable that way:
steps:
- name: checking out repo
uses: actions/checkout#v2
- name: build the schema and validate the data
uses: idrissad/jsonschema_validator#main
id: validation
with:
main_schema_path: ${{ github.workspace }}/schema.json
additional_schemas_dir: ${{ github.workspace }}/GeoJSON_schemas/
data_path: ${{ github.workspace }}/exemple-valide.json

Error after upgrading Joi to latest version - Schema can only contain plain objects (name)

After upgrading Joi to the latest version #hapi/Joi(17.1.1) my server is not staring I am getting below error on startup. Seems there were some breaking changes in recent versions. Not able to get any clue yet, any help is appreciated.
Error: Schema can only contain plain objects (name)
at new module.exports (/Users/xyz/project/projectxyz/node_modules/#hapi/hoek/lib/error.js:23:19)
at module.exports (/Users/xyz/project/projectxyz/node_modules/#hapi/hoek/lib/assert.js:20:11)
at Object.internals.schema (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:88:5)
at Object.exports.schema (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:17:26)
at internals.Base.$_compile (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/base.js:631:24)
at /Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/types/keys.js:255:92
at Object.exports.tryWithPath (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/common.js:173:16)
at internals.Base.method [as keys] (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/types/keys.js:255:32)
at Object.internals.schema (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:90:25)
at Object.exports.schema (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:17:26)
at Object.exports.compile (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:117:24)
at Object.compile (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/index.js:123:24)
at Object.exports.compile (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/validation.js:49:22)
at module.exports.internals.Route._setupValidation (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/route.js:197:43)
at new module.exports.internals.Route (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/route.js:122:14)
at internals.Server._addRoute (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/server.js:498:23)
at internals.Server.route (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/server.js:491:22)
at /Users/xyz/project/projectxyz/src/app.js:73:14
at Array.forEach (<anonymous>)
at init (/Users/xyz/project/projectxyz/src/app.js:72:17)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:66:3) {
path: 'name'
} Server Init error Error: Schema can only contain plain objects (name)
at new module.exports (/Users/xyz/project/projectxyz/node_modules/#hapi/hoek/lib/error.js:23:19)
at module.exports (/Users/xyz/project/projectxyz/node_modules/#hapi/hoek/lib/assert.js:20:11)
at Object.internals.schema (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:88:5)
at Object.exports.schema (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:17:26)
at internals.Base.$_compile (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/base.js:631:24)
at /Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/types/keys.js:255:92
at Object.exports.tryWithPath (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/common.js:173:16)
at internals.Base.method [as keys] (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/types/keys.js:255:32)
at Object.internals.schema (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:90:25)
at Object.exports.schema (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:17:26)
at Object.exports.compile (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/compile.js:117:24)
at Object.compile (/Users/xyz/project/projectxyz/node_modules/#hapi/joi/lib/index.js:123:24)
at Object.exports.compile (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/validation.js:49:22)
at module.exports.internals.Route._setupValidation (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/route.js:197:43)
at new module.exports.internals.Route (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/route.js:122:14)
at internals.Server._addRoute (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/server.js:498:23)
at internals.Server.route (/Users/xyz/project/projectxyz/node_modules/#hapi/hapi/lib/server.js:491:22)
at /Users/xyz/project/projectxyz/src/app.js:73:14
at Array.forEach (<anonymous>)
at init (/Users/xyz/project/projectxyz/src/app.js:72:17)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:66:3) {
path: 'name'
}
To anyone who finds themselves in this dark place again, for me it was an issue when extending a Joi schema using the spread operator:
joi.object().keys({
...otherSchema,
position: joi.number()
})
This was causing the "Schema can only contain plain objects" error when I upgraded to Joi 17.5.0. Using the keys() syntax got around it:
otherSchema.keys({
position: joi.number()
})
Thanks all for your comments. I was able to resolve it after going through Joi's release notes.
The problem was due to the mix of Joi versions. In my codebase older version of Joi was used which was causing this. Below Github issue helped me realizing the issue.
https://github.com/hapijs/joi/issues/1913
i think u should do some thing like this to handle this error:
var ObjectJoi = Joi.object({
//some item that you want to add
})
var mySchema = new Schema(Joigoose.convert(ObjectJoi))
const myModel = mongoose.model('myModel', mySchema);
It's hard to tell without seeing the code.
But I faced the same issue when using Joi.extend().
const extendedType = Joi.extend(Joi => {
return {
type: 'myType', // <- PAY ATTENTION
base: Joi.array(),
messages: {
'stringArray:base': '...'
},
validate(value, helpers) {
...
},
coerce(value, helpers) {
...
}
}
});
The problem was that I used extendedType like below by mistake:
Joi.object({
someKey: extendedType,
...
});
instead of:
Joi.object({
someKey: extendedType.myType(),
...
});

TypeError: has no method 'async'

I'm trying to run the Async example and have the following code:
registerSuite({
name: 'Test Dashboard empty after removing all projects and data',
setup: function () {
var dfd = this.async(1000);
console.info('\n In setup');
remote = this.remote;
remote.setWindowSize(1024,768);
When I run this, I'm seeing the following error:
TypeError: Object #<Suite> has no method 'async'
at Suite.registerSuite.setup <tests/dashboard/dashboard_empty.js:18:28>
at <Suite.target.(anonymous function).dispatcher [as setup] (/home/bkuhlman/internjs_func/Lopez-Internjs-Func/node_modules/intern/node_modules/dojo/aspect.js:95:31)>
at callOnSuite <node_modules/intern/lib/Suite.js:157:42>
at call <node_modules/intern/lib/Suite.js:208:13>
at Suite.run <node_modules/intern/lib/Suite.js:306:4>
at <node_modules/intern/lib/Suite.js:237:13>
at signalListener <node_modules/intern/node_modules/dojo/Deferred.js:37:21>
at Promise.then.promise.then <node_modules/intern/node_modules/dojo/Deferred.js:258:5>
at runTest <node_modules/intern/lib/Suite.js:236:46>
at <node_modules/intern/lib/Suite.js:249:7>
What am I missing?
Thanks,
Brad
It is as the error describes. setup is a suite lifecycle method, not a test method, so it has no this.async. If you need to perform an asynchronous operation from a lifecycle method you will need to return a promise. This will be addressed in a future version of Intern.

Resources