construct-hub 0.3.194 → 0.3.195
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +223 -22
- package/API.md +152 -1
- package/README.md +8 -0
- package/changelog.md +6 -1
- package/lib/backend/ingestion/ingestion.lambda.bundle/index.js +47 -12
- package/lib/backend/ingestion/ingestion.lambda.bundle/index.js.map +2 -2
- package/lib/backend/ingestion/ingestion.lambda.js +6 -4
- package/lib/backend/shared/tags.d.ts +8 -3
- package/lib/backend/shared/tags.js +48 -13
- package/lib/construct-hub.js +1 -1
- package/lib/package-sources/code-artifact.js +1 -1
- package/lib/package-sources/npmjs.js +1 -1
- package/lib/package-tag/index.d.ts +71 -1
- package/lib/package-tag/index.js +53 -10
- package/lib/package-tag-group/index.js +2 -2
- package/lib/preload-file/index.js +1 -1
- package/lib/s3/storage.js +1 -1
- package/lib/spdx-license.js +1 -1
- package/package.json +1 -1
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
package/API.md
CHANGED
@@ -1924,6 +1924,8 @@ const tagConditionConfig: TagConditionConfig = { ... }
|
|
1924
1924
|
| [`type`](#constructhubtagconditionconfigpropertytype)<span title="Required">*</span> | [`construct-hub.TagConditionLogicType`](#construct-hub.TagConditionLogicType) | *No description.* |
|
1925
1925
|
| [`children`](#constructhubtagconditionconfigpropertychildren) | [`construct-hub.TagConditionConfig`](#construct-hub.TagConditionConfig)[] | *No description.* |
|
1926
1926
|
| [`key`](#constructhubtagconditionconfigpropertykey) | `string`[] | *No description.* |
|
1927
|
+
| [`options`](#constructhubtagconditionconfigpropertyoptions) | {[ key: string ]: `any`} | *No description.* |
|
1928
|
+
| [`source`](#constructhubtagconditionconfigpropertysource) | [`construct-hub.TagConditionSource`](#construct-hub.TagConditionSource) | *No description.* |
|
1927
1929
|
| [`value`](#constructhubtagconditionconfigpropertyvalue) | `string` | *No description.* |
|
1928
1930
|
|
1929
1931
|
---
|
@@ -1958,6 +1960,26 @@ public readonly key: string[];
|
|
1958
1960
|
|
1959
1961
|
---
|
1960
1962
|
|
1963
|
+
##### `options`<sup>Optional</sup> <a name="construct-hub.TagConditionConfig.property.options" id="constructhubtagconditionconfigpropertyoptions"></a>
|
1964
|
+
|
1965
|
+
```typescript
|
1966
|
+
public readonly options: {[ key: string ]: any};
|
1967
|
+
```
|
1968
|
+
|
1969
|
+
- *Type:* {[ key: string ]: `any`}
|
1970
|
+
|
1971
|
+
---
|
1972
|
+
|
1973
|
+
##### `source`<sup>Optional</sup> <a name="construct-hub.TagConditionConfig.property.source" id="constructhubtagconditionconfigpropertysource"></a>
|
1974
|
+
|
1975
|
+
```typescript
|
1976
|
+
public readonly source: TagConditionSource;
|
1977
|
+
```
|
1978
|
+
|
1979
|
+
- *Type:* [`construct-hub.TagConditionSource`](#construct-hub.TagConditionSource)
|
1980
|
+
|
1981
|
+
---
|
1982
|
+
|
1961
1983
|
##### `value`<sup>Optional</sup> <a name="construct-hub.TagConditionConfig.property.value" id="constructhubtagconditionconfigpropertyvalue"></a>
|
1962
1984
|
|
1963
1985
|
```typescript
|
@@ -1968,6 +1990,55 @@ public readonly value: string;
|
|
1968
1990
|
|
1969
1991
|
---
|
1970
1992
|
|
1993
|
+
### TagConditionIncludesOptions <a name="construct-hub.TagConditionIncludesOptions" id="constructhubtagconditionincludesoptions"></a>
|
1994
|
+
|
1995
|
+
Options for `includes` operator.
|
1996
|
+
|
1997
|
+
#### Initializer <a name="[object Object].Initializer" id="object-objectinitializer"></a>
|
1998
|
+
|
1999
|
+
```typescript
|
2000
|
+
import { TagConditionIncludesOptions } from 'construct-hub'
|
2001
|
+
|
2002
|
+
const tagConditionIncludesOptions: TagConditionIncludesOptions = { ... }
|
2003
|
+
```
|
2004
|
+
|
2005
|
+
#### Properties <a name="Properties" id="properties"></a>
|
2006
|
+
|
2007
|
+
| **Name** | **Type** | **Description** |
|
2008
|
+
| --- | --- | --- |
|
2009
|
+
| [`atLeast`](#constructhubtagconditionincludesoptionspropertyatleast) | `number` | The value must appear at least this many times. |
|
2010
|
+
| [`caseSensitive`](#constructhubtagconditionincludesoptionspropertycasesensitive) | `boolean` | String matches must match the casing of the original string. |
|
2011
|
+
|
2012
|
+
---
|
2013
|
+
|
2014
|
+
##### `atLeast`<sup>Optional</sup> <a name="construct-hub.TagConditionIncludesOptions.property.atLeast" id="constructhubtagconditionincludesoptionspropertyatleast"></a>
|
2015
|
+
|
2016
|
+
```typescript
|
2017
|
+
public readonly atLeast: number;
|
2018
|
+
```
|
2019
|
+
|
2020
|
+
- *Type:* `number`
|
2021
|
+
- *Default:* 1
|
2022
|
+
|
2023
|
+
The value must appear at least this many times.
|
2024
|
+
|
2025
|
+
---
|
2026
|
+
|
2027
|
+
##### `caseSensitive`<sup>Optional</sup> <a name="construct-hub.TagConditionIncludesOptions.property.caseSensitive" id="constructhubtagconditionincludesoptionspropertycasesensitive"></a>
|
2028
|
+
|
2029
|
+
```typescript
|
2030
|
+
public readonly caseSensitive: boolean;
|
2031
|
+
```
|
2032
|
+
|
2033
|
+
- *Type:* `boolean`
|
2034
|
+
- *Default:* false
|
2035
|
+
|
2036
|
+
String matches must match the casing of the original string.
|
2037
|
+
|
2038
|
+
This option is ignored if the value we are checking is an array.
|
2039
|
+
|
2040
|
+
---
|
2041
|
+
|
1971
2042
|
## Classes <a name="Classes" id="classes"></a>
|
1972
2043
|
|
1973
2044
|
### FilterType <a name="construct-hub.FilterType" id="constructhubfiltertype"></a>
|
@@ -7292,6 +7363,7 @@ public bind()
|
|
7292
7363
|
| [`field`](#constructhubtagconditionfield) | Target a field within the `package.json` to assert against. Nested fields can be accessed by passing multiple keys. `TagCondition.field('key1', 'key2')` will access `packageJson?.key1?.key2`. |
|
7293
7364
|
| [`not`](#constructhubtagconditionnot) | Create a ! |
|
7294
7365
|
| [`or`](#constructhubtagconditionor) | Create an \|\| condition which applies if any of the condition arguments are true. |
|
7366
|
+
| [`readme`](#constructhubtagconditionreadme) | Create a condition with logic targeting the README of the package. |
|
7295
7367
|
|
7296
7368
|
---
|
7297
7369
|
|
@@ -7351,6 +7423,14 @@ TagCondition.or(conds: TagCondition)
|
|
7351
7423
|
|
7352
7424
|
---
|
7353
7425
|
|
7426
|
+
##### `readme` <a name="construct-hub.TagCondition.readme" id="constructhubtagconditionreadme"></a>
|
7427
|
+
|
7428
|
+
```typescript
|
7429
|
+
import { TagCondition } from 'construct-hub'
|
7430
|
+
|
7431
|
+
TagCondition.readme()
|
7432
|
+
```
|
7433
|
+
|
7354
7434
|
|
7355
7435
|
|
7356
7436
|
### TagConditionField <a name="construct-hub.TagConditionField" id="constructhubtagconditionfield"></a>
|
@@ -7402,7 +7482,7 @@ public eq(value: any)
|
|
7402
7482
|
##### `includes` <a name="construct-hub.TagConditionField.includes" id="constructhubtagconditionfieldincludes"></a>
|
7403
7483
|
|
7404
7484
|
```typescript
|
7405
|
-
public includes(value: any)
|
7485
|
+
public includes(value: any, options?: TagConditionIncludesOptions)
|
7406
7486
|
```
|
7407
7487
|
|
7408
7488
|
###### `value`<sup>Required</sup> <a name="construct-hub.TagConditionField.parameter.value" id="constructhubtagconditionfieldparametervalue"></a>
|
@@ -7411,6 +7491,12 @@ public includes(value: any)
|
|
7411
7491
|
|
7412
7492
|
---
|
7413
7493
|
|
7494
|
+
###### `options`<sup>Optional</sup> <a name="construct-hub.TagConditionField.parameter.options" id="constructhubtagconditionfieldparameteroptions"></a>
|
7495
|
+
|
7496
|
+
- *Type:* [`construct-hub.TagConditionIncludesOptions`](#construct-hub.TagConditionIncludesOptions)
|
7497
|
+
|
7498
|
+
---
|
7499
|
+
|
7414
7500
|
##### `startsWith` <a name="construct-hub.TagConditionField.startsWith" id="constructhubtagconditionfieldstartswith"></a>
|
7415
7501
|
|
7416
7502
|
```typescript
|
@@ -7426,6 +7512,52 @@ public startsWith(value: string)
|
|
7426
7512
|
|
7427
7513
|
|
7428
7514
|
|
7515
|
+
### TagConditionReadme <a name="construct-hub.TagConditionReadme" id="constructhubtagconditionreadme"></a>
|
7516
|
+
|
7517
|
+
Target the README of the package to dictate whether a tag is relevant.
|
7518
|
+
|
7519
|
+
#### Initializers <a name="construct-hub.TagConditionReadme.Initializer" id="constructhubtagconditionreadmeinitializer"></a>
|
7520
|
+
|
7521
|
+
```typescript
|
7522
|
+
import { TagConditionReadme } from 'construct-hub'
|
7523
|
+
|
7524
|
+
new TagConditionReadme()
|
7525
|
+
```
|
7526
|
+
|
7527
|
+
| **Name** | **Type** | **Description** |
|
7528
|
+
| --- | --- | --- |
|
7529
|
+
|
7530
|
+
---
|
7531
|
+
|
7532
|
+
#### Methods <a name="Methods" id="methods"></a>
|
7533
|
+
|
7534
|
+
| **Name** | **Description** |
|
7535
|
+
| --- | --- |
|
7536
|
+
| [`includes`](#constructhubtagconditionreadmeincludes) | Create a `readme.includes(value)` condition which applies if the README includes the specified string. |
|
7537
|
+
|
7538
|
+
---
|
7539
|
+
|
7540
|
+
##### `includes` <a name="construct-hub.TagConditionReadme.includes" id="constructhubtagconditionreadmeincludes"></a>
|
7541
|
+
|
7542
|
+
```typescript
|
7543
|
+
public includes(value: string, options?: TagConditionIncludesOptions)
|
7544
|
+
```
|
7545
|
+
|
7546
|
+
###### `value`<sup>Required</sup> <a name="construct-hub.TagConditionReadme.parameter.value" id="constructhubtagconditionreadmeparametervalue"></a>
|
7547
|
+
|
7548
|
+
- *Type:* `string`
|
7549
|
+
|
7550
|
+
---
|
7551
|
+
|
7552
|
+
###### `options`<sup>Optional</sup> <a name="construct-hub.TagConditionReadme.parameter.options" id="constructhubtagconditionreadmeparameteroptions"></a>
|
7553
|
+
|
7554
|
+
- *Type:* [`construct-hub.TagConditionIncludesOptions`](#construct-hub.TagConditionIncludesOptions)
|
7555
|
+
|
7556
|
+
---
|
7557
|
+
|
7558
|
+
|
7559
|
+
|
7560
|
+
|
7429
7561
|
## Protocols <a name="Protocols" id="protocols"></a>
|
7430
7562
|
|
7431
7563
|
### IDenyList <a name="construct-hub.IDenyList" id="constructhubidenylist"></a>
|
@@ -7689,3 +7821,22 @@ Logic operators for performing specific conditional logic.
|
|
7689
7821
|
|
7690
7822
|
---
|
7691
7823
|
|
7824
|
+
|
7825
|
+
### TagConditionSource <a name="TagConditionSource" id="tagconditionsource"></a>
|
7826
|
+
|
7827
|
+
| **Name** | **Description** |
|
7828
|
+
| --- | --- |
|
7829
|
+
| [`PACKAGE_JSON`](#constructhubtagconditionsourcepackagejson) | *No description.* |
|
7830
|
+
| [`README`](#constructhubtagconditionsourcereadme) | *No description.* |
|
7831
|
+
|
7832
|
+
---
|
7833
|
+
|
7834
|
+
#### `PACKAGE_JSON` <a name="construct-hub.TagConditionSource.PACKAGE_JSON" id="constructhubtagconditionsourcepackagejson"></a>
|
7835
|
+
|
7836
|
+
---
|
7837
|
+
|
7838
|
+
|
7839
|
+
#### `README` <a name="construct-hub.TagConditionSource.README" id="constructhubtagconditionsourcereadme"></a>
|
7840
|
+
|
7841
|
+
---
|
7842
|
+
|
package/README.md
CHANGED
@@ -347,6 +347,14 @@ TagCondition.field('constructHub', 'nested', 'key').eq('value');
|
|
347
347
|
packageJson?.constructHub?.nested?.key === value;
|
348
348
|
```
|
349
349
|
|
350
|
+
You can also assert that a string occurs at least a certain number of times
|
351
|
+
within the package's README.
|
352
|
+
|
353
|
+
```ts
|
354
|
+
TagCondition.readme().includes('ECS');
|
355
|
+
TagCondition.readme().includes('fargate', { atLeast: 3, caseSensitive: false });
|
356
|
+
```
|
357
|
+
|
350
358
|
#### Package Links
|
351
359
|
|
352
360
|
Configuring package links allows you to replace the `Repository`, `License`,
|
package/changelog.md
CHANGED
@@ -1,2 +1,7 @@
|
|
1
1
|
|
2
|
-
### [0.3.
|
2
|
+
### [0.3.195](https://github.com/cdklabs/construct-hub/compare/v0.3.194...v0.3.195) (2022-01-12)
|
3
|
+
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
* tag condition type for README contents ([#709](https://github.com/cdklabs/construct-hub/issues/709)) ([09837fe](https://github.com/cdklabs/construct-hub/commit/09837fe275f054d60d03ca908083036767c97970)), closes [#625](https://github.com/cdklabs/construct-hub/issues/625)
|
@@ -81730,33 +81730,66 @@ function integrity(input, tarball, alg = ((_a) => (_a = input.integrity) == null
|
|
81730
81730
|
}
|
81731
81731
|
|
81732
81732
|
// src/backend/shared/tags.ts
|
81733
|
-
function getNestedField(
|
81734
|
-
|
81733
|
+
function getNestedField(config, artifacts) {
|
81734
|
+
switch (config == null ? void 0 : config.source) {
|
81735
|
+
case "PACKAGE_JSON" /* PACKAGE_JSON */:
|
81736
|
+
const path = config == null ? void 0 : config.key;
|
81737
|
+
return path == null ? void 0 : path.reduce((accum, key) => accum ? accum[key] : void 0, artifacts.pkg);
|
81738
|
+
case "README" /* README */:
|
81739
|
+
return artifacts.readme;
|
81740
|
+
default:
|
81741
|
+
throw new Error(`Unexpected TagConditionConfig source: "${config.source}"`);
|
81742
|
+
}
|
81735
81743
|
}
|
81736
|
-
var createBoolCombinator = (combine, initial) => (config,
|
81744
|
+
var createBoolCombinator = (combine, initial) => (config, artifacts) => {
|
81737
81745
|
var _a;
|
81738
|
-
return ((_a = config == null ? void 0 : config.children) == null ? void 0 : _a.reduce((accum, cond) => combine(accum, isTagApplicable(cond,
|
81746
|
+
return ((_a = config == null ? void 0 : config.children) == null ? void 0 : _a.reduce((accum, cond) => combine(accum, isTagApplicable(cond, artifacts)), initial)) ?? true;
|
81739
81747
|
};
|
81740
|
-
var createFieldComparator = (compare) => (config,
|
81741
|
-
var not = (config,
|
81748
|
+
var createFieldComparator = (compare) => (config, artifacts) => compare(getNestedField(config, artifacts), config == null ? void 0 : config.value, config == null ? void 0 : config.options);
|
81749
|
+
var not = (config, artifacts) => {
|
81742
81750
|
var _a;
|
81743
81751
|
const cond = (_a = config == null ? void 0 : config.children) == null ? void 0 : _a[0];
|
81744
81752
|
if (!cond) {
|
81745
81753
|
throw new Error("NOT logical operator requires a single condition");
|
81746
81754
|
}
|
81747
|
-
return !isTagApplicable(cond,
|
81755
|
+
return !isTagApplicable(cond, artifacts);
|
81756
|
+
};
|
81757
|
+
var checkIncludes = (haystack, needle, options = {}) => {
|
81758
|
+
const atLeast = options.atLeast ?? 1;
|
81759
|
+
const caseSensitive = options.caseSensitive ?? false;
|
81760
|
+
if (typeof haystack === "string") {
|
81761
|
+
if (typeof needle !== "string") {
|
81762
|
+
return false;
|
81763
|
+
}
|
81764
|
+
if (!caseSensitive) {
|
81765
|
+
needle = needle.toLowerCase();
|
81766
|
+
haystack = haystack.toLowerCase();
|
81767
|
+
}
|
81768
|
+
const matches = haystack.match(new RegExp(needle, "g")) ?? [];
|
81769
|
+
return matches.length >= atLeast;
|
81770
|
+
}
|
81771
|
+
if (Array.isArray(haystack)) {
|
81772
|
+
let matches = 0;
|
81773
|
+
for (const item of haystack) {
|
81774
|
+
if (item === needle) {
|
81775
|
+
matches += 1;
|
81776
|
+
}
|
81777
|
+
}
|
81778
|
+
return matches >= atLeast;
|
81779
|
+
}
|
81780
|
+
return false;
|
81748
81781
|
};
|
81749
|
-
function isTagApplicable(config,
|
81782
|
+
function isTagApplicable(config, artifacts) {
|
81750
81783
|
const fnMap = {
|
81751
81784
|
["AND" /* AND */]: createBoolCombinator((field, val) => field && val, true),
|
81752
81785
|
["OR" /* OR */]: createBoolCombinator((field, val) => field || val, false),
|
81753
81786
|
["EQUALS" /* EQUALS */]: createFieldComparator((field, val) => field === val),
|
81754
|
-
["INCLUDES" /* INCLUDES */]: createFieldComparator((field, val) => field.
|
81787
|
+
["INCLUDES" /* INCLUDES */]: createFieldComparator((field, val) => checkIncludes(field, val, config.options)),
|
81755
81788
|
["STARTS_WITH" /* STARTS_WITH */]: createFieldComparator((field, val) => field.startsWith(val)),
|
81756
81789
|
["NOT" /* NOT */]: not
|
81757
81790
|
};
|
81758
81791
|
const fn = fnMap[config.type] ?? (() => false);
|
81759
|
-
return fn(config,
|
81792
|
+
return fn(config, artifacts);
|
81760
81793
|
}
|
81761
81794
|
|
81762
81795
|
// src/backend/shared/tarball.lambda-shared.ts
|
@@ -81927,13 +81960,15 @@ var handler = (0, import_aws_embedded_metrics.metricScope)((metrics) => async (e
|
|
81927
81960
|
let packageLicense;
|
81928
81961
|
let packageName;
|
81929
81962
|
let packageVersion;
|
81963
|
+
let packageReadme;
|
81930
81964
|
try {
|
81931
81965
|
parsedAssembly = (0, import_spec.validateAssembly)(JSON.parse(dotJsii.toString("utf-8")));
|
81932
81966
|
constructFramework = detectConstructFramework(parsedAssembly);
|
81933
|
-
const { license, name, version } = parsedAssembly;
|
81967
|
+
const { license, name, version, readme } = parsedAssembly;
|
81934
81968
|
packageLicense = license;
|
81935
81969
|
packageName = name;
|
81936
81970
|
packageVersion = version;
|
81971
|
+
packageReadme = (readme == null ? void 0 : readme.markdown) ?? "";
|
81937
81972
|
delete parsedAssembly.types;
|
81938
81973
|
delete parsedAssembly.readme;
|
81939
81974
|
delete parsedAssembly.dependencyClosure;
|
@@ -81970,7 +82005,7 @@ var handler = (0, import_aws_embedded_metrics.metricScope)((metrics) => async (e
|
|
81970
82005
|
}, {});
|
81971
82006
|
const packageTags = packageTagsConfig.reduce((accum, tagConfig) => {
|
81972
82007
|
const _a = tagConfig, { condition } = _a, tagData = __objRest(_a, ["condition"]);
|
81973
|
-
if (isTagApplicable(condition, packageJsonObj)) {
|
82008
|
+
if (isTagApplicable(condition, { pkg: packageJsonObj, readme: packageReadme })) {
|
81974
82009
|
return [...accum, tagData];
|
81975
82010
|
}
|
81976
82011
|
return accum;
|