Comments (7)
I think, the tests itself are a little bit hacky/undocumented stuff using serverless somehow you shouldn't use it, maybe.
When I use the changes and create a demo project using the {git:xyz} it is working without any warning from serverless. So I guess the change itself is correct.
from serverless-plugin-git-variables.
With the latest resolver, a plugin should the pattern: https://www.serverless.com/framework/docs/providers/aws/guide/plugins#custom-variable-types
A replacement could look like:
diff --git a/src/index.js b/src/index.js
index a5f1a50..33edef8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -21,15 +21,15 @@ export default class ServerlessGitVariables {
constructor(serverless, options) {
this.serverless = serverless
this.resolvedValues = {}
- const delegate = serverless.variables.getValueFromSource.bind(serverless.variables)
- serverless.variables.getValueFromSource = (variableString) => {
- if (variableString.startsWith(`${GIT_PREFIX}:`)) {
- const variable = variableString.split(`${GIT_PREFIX}:`)[1]
- return this._getValue(variable)
+ this.configurationVariablesSources = {
+ [GIT_PREFIX]: {
+ resolve: async ({ address, params, resolveConfigurationProperty, options }) => {
+ return {
+ value: await this._getValue(address)
+ }
+ }
}
-
- return delegate(variableString)
}
this.hooks = {
'after:package:initialize': this.exportGitVariables.bind(this),
from serverless-plugin-git-variables.
Unfortunately I wasn't able to change the test in lag of serverless documentation and my rough js skills.
from serverless-plugin-git-variables.
@Wurstnase I tried to pick up on your work, but something seems strange - I'm not sure the tests simply need to be adapted? Each call now rejects with Invalid variable reference syntax for variable git:describe. You can only reference env vars, options, & files. You can check our docs for more info.
. But it should be possible to use custom variables with the resolver syntax you detailed. Did you get the same result or what changes to the tests were you referring to?
from serverless-plugin-git-variables.
You may need to update the package.json also. I've updated the complete package.json to the latest packages.
Maybe it will work with less and I don't know how to handle the "peerDependencies" correctly.
However, with this change I was able to use the git plugin within a minimal serverless.yml.
service: test
provider: aws
custom:
value: ${git:sha1}
plugins:
- ./lib
diff --git a/package.json b/package.json
index c5832d7..51603f7 100644
--- a/package.json
+++ b/package.json
@@ -42,30 +42,30 @@
},
"devDependencies": {
"@ava/babel": "1.0.1",
- "@babel/cli": "7.12.1",
- "@babel/core": "7.12.3",
- "@babel/preset-env": "7.12.1",
- "@babel/register": "7.12.1",
- "ava": "3.13.0",
+ "@babel/cli": "7.13.16",
+ "@babel/core": "7.14.2",
+ "@babel/preset-env": "7.14.2",
+ "@babel/register": "7.13.16",
+ "ava": "3.15.0",
"babel-plugin-add-module-exports": "1.0.4",
"coveralls": "3.1.0",
- "cross-env": "7.0.2",
- "eslint": "7.12.1",
- "eslint-config-standard": "16.0.1",
- "eslint-plugin-ava": "11.0.0",
+ "cross-env": "7.0.3",
+ "eslint": "7.26.0",
+ "eslint-config-standard": "16.0.2",
+ "eslint-plugin-ava": "12.0.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-node": "11.1.0",
- "eslint-plugin-promise": "4.2.1",
- "eslint-plugin-standard": "4.0.2",
- "fs-extra": "9.0.1",
+ "eslint-plugin-promise": "5.1.0",
+ "eslint-plugin-standard": "4.1.0",
+ "fs-extra": "10.0.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
- "serverless": "1.17.0",
+ "serverless": ">=2.43.1",
"tmp": "0.2.1"
},
"modules": true,
"peerDependencies": {
- "serverless": ">=1.16.0"
+ "serverless": ">=2.43.1"
},
"ava": {
"require": [
from serverless-plugin-git-variables.
@Wurstnase Updating package.json
didn't help, it's part of #76 and I verified serverless 2.43.1 was used.
from serverless-plugin-git-variables.
This should now be fixed and work for sls v1, v2, and v3. Thanks!
from serverless-plugin-git-variables.
Related Issues (20)
- Add client-side validation of git variables
- Git remote HOT 1
- Cannot install - Node 8 only? HOT 2
- Injected variables not included in `serverless print` HOT 2
- Refactor to use NodeGit HOT 1
- Release 3.3.0 fails with invalid git command HOT 5
- sporadic git command failed "git write-tree" HOT 15
- Git Command Fails - Suspected Timeout HOT 4
- Wrong values in env vars HOT 3
- "Rejects on bad git command" test fails
- Document isDirty HOT 1
- Display GIT_USER and GIT_EMAIL by default HOT 1
- Failing build when more then one tag points to commit HOT 4
- GIT_USER and GIT_EMAIL are not exported by default HOT 2
- Old version of babel-runtime with deprecated core-js HOT 4
- Feature request: Add support for commit subject HOT 1
- Staged changes are not counted as 'dirty' by git:isDirty HOT 1
- Not works for Windows HOT 1
- Integration with Serverless Framework v3 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-plugin-git-variables.