@cdktf/provider-acme 10.0.0 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.jsii +345 -224
- package/LICENSE +1 -1
- package/README.md +11 -13
- package/lib/certificate/index.d.ts +50 -32
- package/lib/certificate/index.js +293 -14
- package/lib/provider/index.d.ts +8 -5
- package/lib/provider/index.js +24 -6
- package/lib/registration/index.d.ts +13 -9
- package/lib/registration/index.js +63 -8
- package/package.json +17 -17
- package/.copywrite.hcl +0 -24
- package/.gitattributes +0 -36
- package/scripts/check-for-upgrades.js +0 -152
- package/scripts/should-release.js +0 -78
@@ -1,152 +0,0 @@
|
|
1
|
-
|
2
|
-
/**
|
3
|
-
* Copyright (c) HashiCorp, Inc.
|
4
|
-
* SPDX-License-Identifier: MPL-2.0
|
5
|
-
*/
|
6
|
-
const fetch = require("node-fetch");
|
7
|
-
const semver = require("semver");
|
8
|
-
const actions = require("@actions/core");
|
9
|
-
|
10
|
-
// Code is inlined below, as this import requires us to add all dev dependencies of cdktf-cli as we're not
|
11
|
-
// using the bundle. A better alternative would be to refactor this method to move to its own package, that
|
12
|
-
// the cdktf-cli and others can use (we have the same "problem" with some other code in cdktf, cdktf-cli and
|
13
|
-
// the @cdktf/provider-generator package, too)
|
14
|
-
// const { versionMatchesConstraint } = require('cdktf-cli/lib/dependencies/version-constraints');
|
15
|
-
|
16
|
-
// set by the projen file that generates this script
|
17
|
-
const CONSTRAINT = "~> 2.10";
|
18
|
-
const FQ_PROVIDER_NAME = "vancluever/acme";
|
19
|
-
|
20
|
-
(async function main() {
|
21
|
-
if (await newerMatchingProviderVersionExists()) {
|
22
|
-
console.log(
|
23
|
-
`Found newer Terraform provider version matching the current constraint: ${CONSTRAINT}`
|
24
|
-
);
|
25
|
-
setGithubStepOutput("new_version", "available");
|
26
|
-
} else {
|
27
|
-
console.log("No changes detected.");
|
28
|
-
setGithubStepOutput("new_version", "unavailable");
|
29
|
-
}
|
30
|
-
})();
|
31
|
-
|
32
|
-
function setGithubStepOutput(name, value) {
|
33
|
-
actions.setOutput(name, value);
|
34
|
-
}
|
35
|
-
|
36
|
-
async function newerMatchingProviderVersionExists() {
|
37
|
-
const res = await fetch(
|
38
|
-
`https://registry.terraform.io/v2/providers/${FQ_PROVIDER_NAME}/provider-versions`
|
39
|
-
);
|
40
|
-
const body = await res.json();
|
41
|
-
|
42
|
-
const currentVersion = await getCurrentProviderVersion();
|
43
|
-
|
44
|
-
const availableVersions = body.data.map((it) => it.attributes.version);
|
45
|
-
const versionsMatching = availableVersions.filter((v) =>
|
46
|
-
versionMatchesConstraint(v, CONSTRAINT)
|
47
|
-
);
|
48
|
-
if (versionsMatching.length <= 0) {
|
49
|
-
throw new Error(
|
50
|
-
`Unexpected Error: Found no matching versions for constraint ${CONSTRAINT} in [${availableVersions.join(
|
51
|
-
", "
|
52
|
-
)}]`
|
53
|
-
);
|
54
|
-
}
|
55
|
-
|
56
|
-
const versionsGreaterThanCurrent = versionsMatching.filter((v) =>
|
57
|
-
semver.gt(v, currentVersion)
|
58
|
-
);
|
59
|
-
if (versionsGreaterThanCurrent.length > 0) {
|
60
|
-
console.log(
|
61
|
-
`One or more matching versions (${CONSTRAINT}) are greater than the current version (${currentVersion}): [${versionsGreaterThanCurrent.join(
|
62
|
-
", "
|
63
|
-
)}]`
|
64
|
-
);
|
65
|
-
return true;
|
66
|
-
} else {
|
67
|
-
console.log(
|
68
|
-
`Found no matching versions (${CONSTRAINT}) greater than the current version (${currentVersion}). Matching versions: [${versionsMatching.join(
|
69
|
-
", "
|
70
|
-
)}]`
|
71
|
-
);
|
72
|
-
}
|
73
|
-
return false;
|
74
|
-
}
|
75
|
-
|
76
|
-
// e.g. cdktf 0.12.x -> 0.13.x but not 0.12.y -> 0.12.z
|
77
|
-
async function cdktfVersionMajorChanged() {
|
78
|
-
throw new Error("todo implement");
|
79
|
-
}
|
80
|
-
|
81
|
-
async function getCurrentProviderVersion() {
|
82
|
-
const json = require("../src/version.json");
|
83
|
-
return json[`registry.terraform.io/${FQ_PROVIDER_NAME.toLowerCase()}`];
|
84
|
-
}
|
85
|
-
|
86
|
-
// SEE NOTICE AT THE TOP WHY THIS IS INLINED CURRENTLY
|
87
|
-
// copied from https://github.com/hashicorp/terraform-cdk/blob/b23fc173715e90c0a5b8c8633d9ec7f71edf9ed4/packages/cdktf-cli/lib/dependencies/version-constraints.ts
|
88
|
-
// and converted to JavaScript
|
89
|
-
|
90
|
-
// constraints can be prefixed with "~>", ">", "<", "=", ">=", "<=" or "!="
|
91
|
-
// no prefix means "="
|
92
|
-
function parseConstraint(constraint) {
|
93
|
-
const cleaned = constraint.trim();
|
94
|
-
|
95
|
-
const operator = cleaned.match(/(~>|>=|<=|>|<|=|!=)/)?.[0] || "=";
|
96
|
-
const version = cleaned.replace(operator, "").trim();
|
97
|
-
|
98
|
-
return {
|
99
|
-
operator,
|
100
|
-
version,
|
101
|
-
};
|
102
|
-
}
|
103
|
-
|
104
|
-
function versionMatchesConstraint(version, constraint) {
|
105
|
-
// https://www.terraform.io/language/expressions/version-constraints
|
106
|
-
// version can contain multiple constraints split by ","
|
107
|
-
|
108
|
-
const constraints = constraint.split(",");
|
109
|
-
version = semver.coerce(version)?.version ?? version;
|
110
|
-
|
111
|
-
// each constraint needs to be satisfied
|
112
|
-
return constraints.every((c) => {
|
113
|
-
const parsed = parseConstraint(c);
|
114
|
-
|
115
|
-
const cleanedParsedVersion =
|
116
|
-
semver.coerce(parsed.version)?.version ?? parsed.version;
|
117
|
-
|
118
|
-
switch (parsed.operator) {
|
119
|
-
case "=":
|
120
|
-
return version === cleanedParsedVersion;
|
121
|
-
case "!=":
|
122
|
-
return version !== cleanedParsedVersion;
|
123
|
-
case "~>": {
|
124
|
-
// allows rightmost version component to increment
|
125
|
-
|
126
|
-
// ~>2.0 which allows 2.1 and 2.1.1 needs special handling as
|
127
|
-
// npm semver handles "~" differently for ~2.0 than for ~2 or ~2.1.0
|
128
|
-
// So we need to use "^" (e.g. ^2.0) for this case
|
129
|
-
// see: https://github.com/npm/node-semver/issues/11
|
130
|
-
const allowMinorAndPatchOnly = parsed.version.split(".").length === 2;
|
131
|
-
|
132
|
-
const range = allowMinorAndPatchOnly
|
133
|
-
? `^${parsed.version}`
|
134
|
-
: `~${parsed.version}`;
|
135
|
-
|
136
|
-
return semver.satisfies(version, range);
|
137
|
-
}
|
138
|
-
case ">=":
|
139
|
-
return semver.gte(version, cleanedParsedVersion);
|
140
|
-
case "<=":
|
141
|
-
return semver.lte(version, cleanedParsedVersion);
|
142
|
-
case ">":
|
143
|
-
return semver.gt(version, cleanedParsedVersion);
|
144
|
-
case "<":
|
145
|
-
return semver.lt(version, cleanedParsedVersion);
|
146
|
-
default:
|
147
|
-
throw Errors.External(
|
148
|
-
`Unknown constraint operator: ${parsed.operator} in version constraint ${constraint}`
|
149
|
-
);
|
150
|
-
}
|
151
|
-
});
|
152
|
-
}
|
@@ -1,78 +0,0 @@
|
|
1
|
-
|
2
|
-
/**
|
3
|
-
* Copyright (c) HashiCorp, Inc.
|
4
|
-
* SPDX-License-Identifier: MPL-2.0
|
5
|
-
*/
|
6
|
-
// Note: This script is currently not handling pre-releases
|
7
|
-
const execSync = require("child_process").execSync;
|
8
|
-
|
9
|
-
(async function main() {
|
10
|
-
console.log(
|
11
|
-
"Determining whether changes warrant a new release. Non-zero exit code indicates that a release should be skipped"
|
12
|
-
);
|
13
|
-
|
14
|
-
// inspired by https://github.com/projen/projen/blob/08378c40d1453288053abcddce82475329b4506e/src/release/bump-version.ts#L281
|
15
|
-
const prefixFilter = `v*`;
|
16
|
-
const listGitTags = [
|
17
|
-
"git",
|
18
|
-
'-c "versionsort.suffix=-"', // makes sure pre-release versions are listed after the primary version
|
19
|
-
"tag",
|
20
|
-
'--sort="-version:refname"', // sort as versions and not lexicographically
|
21
|
-
"--list",
|
22
|
-
`"${prefixFilter}"`,
|
23
|
-
].join(" ");
|
24
|
-
|
25
|
-
const stdout = execSync(listGitTags).toString();
|
26
|
-
const tags = stdout.split("\n");
|
27
|
-
|
28
|
-
if (tags.length > 0 && tags[0].trim() !== "") {
|
29
|
-
const latestTag = tags[0];
|
30
|
-
console.log(`Found latest tag ${latestTag}`);
|
31
|
-
|
32
|
-
const previousPackageJsonGit = [
|
33
|
-
"git",
|
34
|
-
"show",
|
35
|
-
`${latestTag}:package.json`,
|
36
|
-
].join(" ");
|
37
|
-
const prevPackageJson = JSON.parse(
|
38
|
-
execSync(previousPackageJsonGit).toString()
|
39
|
-
);
|
40
|
-
const currPackageJson = require("../package.json");
|
41
|
-
|
42
|
-
const thingsToDiff = [
|
43
|
-
{
|
44
|
-
name: "Terraform provider version",
|
45
|
-
previous: prevPackageJson.cdktf.provider.version,
|
46
|
-
current: currPackageJson.cdktf.provider.version,
|
47
|
-
},
|
48
|
-
{
|
49
|
-
name: "cdktf peer dependency",
|
50
|
-
previous: prevPackageJson.peerDependencies.cdktf,
|
51
|
-
current: currPackageJson.peerDependencies.cdktf,
|
52
|
-
},
|
53
|
-
];
|
54
|
-
|
55
|
-
thingsToDiff.forEach((x) =>
|
56
|
-
console.log(
|
57
|
-
`${x.name}: ${x.previous} => ${x.current} ${
|
58
|
-
x.current !== x.previous ? "<<CHANGED" : ""
|
59
|
-
}`
|
60
|
-
)
|
61
|
-
);
|
62
|
-
const changes = thingsToDiff.some((x) => x.previous !== x.current);
|
63
|
-
if (changes) {
|
64
|
-
console.log(
|
65
|
-
"Found one or more relevant changes, not skipping the release."
|
66
|
-
);
|
67
|
-
} else {
|
68
|
-
console.log(
|
69
|
-
"No changes in versions detected, skipping the release via exit code 1"
|
70
|
-
);
|
71
|
-
process.exit(1);
|
72
|
-
}
|
73
|
-
} else {
|
74
|
-
console.log(
|
75
|
-
"No git tags found, this seems to be the first release, hence not skipping it."
|
76
|
-
);
|
77
|
-
}
|
78
|
-
})();
|