terraconstructs 0.0.25 → 0.1.1

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.
Files changed (422) hide show
  1. package/.jsii +83939 -55116
  2. package/.mise.toml +2 -2
  3. package/.nvmrc +1 -1
  4. package/LICENSE +202 -674
  5. package/go.mod +1 -1
  6. package/go.sum +2 -2
  7. package/lib/asset-manager.d.ts +23 -0
  8. package/lib/asset-manager.js +3 -0
  9. package/lib/asset-staging.d.ts +178 -0
  10. package/lib/asset-staging.js +589 -0
  11. package/lib/assets.d.ts +359 -0
  12. package/lib/assets.js +55 -0
  13. package/lib/aws/arn.js +16 -15
  14. package/lib/aws/aws-asset-manager.d.ts +91 -0
  15. package/lib/aws/aws-asset-manager.js +244 -0
  16. package/lib/aws/aws-construct.js +1 -1
  17. package/lib/aws/aws-stack.d.ts +37 -0
  18. package/lib/aws/aws-stack.js +30 -9
  19. package/lib/aws/aws-tags.js +2 -2
  20. package/lib/aws/cloudwatch/actions/appscaling.d.ts +15 -0
  21. package/lib/aws/cloudwatch/actions/appscaling.js +24 -0
  22. package/lib/aws/cloudwatch/actions/ec2.js +1 -1
  23. package/lib/aws/cloudwatch/actions/index.d.ts +3 -0
  24. package/lib/aws/cloudwatch/actions/index.js +4 -4
  25. package/lib/aws/cloudwatch/actions/lambda.js +1 -1
  26. package/lib/aws/cloudwatch/actions/sns.d.ts +14 -0
  27. package/lib/aws/cloudwatch/actions/sns.js +23 -0
  28. package/lib/aws/cloudwatch/actions/ssm.d.ts +72 -0
  29. package/lib/aws/cloudwatch/actions/ssm.js +104 -0
  30. package/lib/aws/cloudwatch/alarm-base.js +1 -1
  31. package/lib/aws/cloudwatch/alarm-rule.js +1 -1
  32. package/lib/aws/cloudwatch/alarm-status-widget.js +1 -1
  33. package/lib/aws/cloudwatch/alarm.js +1 -1
  34. package/lib/aws/cloudwatch/composite-alarm.js +1 -1
  35. package/lib/aws/cloudwatch/dashboard.js +1 -1
  36. package/lib/aws/cloudwatch/data-protection-policy.js +3 -3
  37. package/lib/aws/cloudwatch/graph.js +8 -8
  38. package/lib/aws/cloudwatch/layout.js +3 -3
  39. package/lib/aws/cloudwatch/log-destinations/kinesis.js +1 -1
  40. package/lib/aws/cloudwatch/log-destinations/lambda.js +1 -1
  41. package/lib/aws/cloudwatch/log-group.js +1 -1
  42. package/lib/aws/cloudwatch/log-query.js +1 -1
  43. package/lib/aws/cloudwatch/log-stream.js +1 -1
  44. package/lib/aws/cloudwatch/metric-filter.js +1 -1
  45. package/lib/aws/cloudwatch/metric.js +2 -2
  46. package/lib/aws/cloudwatch/pattern.js +3 -3
  47. package/lib/aws/cloudwatch/policy.js +1 -1
  48. package/lib/aws/cloudwatch/query-definition.js +2 -2
  49. package/lib/aws/cloudwatch/stats.js +1 -1
  50. package/lib/aws/cloudwatch/subscription-filter.js +1 -1
  51. package/lib/aws/cloudwatch/text.js +1 -1
  52. package/lib/aws/cloudwatch/variable.js +3 -3
  53. package/lib/aws/cloudwatch/widget.js +1 -1
  54. package/lib/aws/compute/access-log.d.ts +478 -0
  55. package/lib/aws/compute/access-log.js +649 -0
  56. package/lib/aws/compute/activity.js +1 -1
  57. package/lib/aws/compute/alb/application-listener-action.js +1 -1
  58. package/lib/aws/compute/alb/application-listener-certificate.js +1 -1
  59. package/lib/aws/compute/alb/application-listener-rule.js +1 -1
  60. package/lib/aws/compute/alb/application-listener.js +1 -1
  61. package/lib/aws/compute/alb/application-load-balancer.js +1 -1
  62. package/lib/aws/compute/alb/application-target-group.js +1 -1
  63. package/lib/aws/compute/alb/conditions.js +1 -1
  64. package/lib/aws/compute/alb/trust-store-revocation.js +1 -1
  65. package/lib/aws/compute/alb/trust-store.js +1 -1
  66. package/lib/aws/compute/api-definition.d.ts +106 -0
  67. package/lib/aws/compute/api-definition.js +200 -0
  68. package/lib/aws/compute/api-key.d.ts +184 -0
  69. package/lib/aws/compute/api-key.js +197 -0
  70. package/lib/aws/compute/apigateway-canned-metrics.generated.d.ts +169 -0
  71. package/lib/aws/compute/apigateway-canned-metrics.generated.js +63 -0
  72. package/lib/aws/compute/apigateway-util.d.ts +31 -0
  73. package/lib/aws/compute/apigateway-util.js +152 -0
  74. package/lib/aws/compute/architecture.js +1 -1
  75. package/lib/aws/compute/aspects/require-imdsv2-aspect.js +2 -2
  76. package/lib/aws/compute/authorizer.d.ts +35 -0
  77. package/lib/aws/compute/authorizer.js +28 -0
  78. package/lib/aws/compute/authorizers/identity-source.d.ts +37 -0
  79. package/lib/aws/compute/authorizers/identity-source.js +61 -0
  80. package/lib/aws/compute/authorizers/index.d.ts +2 -0
  81. package/lib/aws/compute/authorizers/index.js +20 -0
  82. package/lib/aws/compute/authorizers/lambda.d.ts +140 -0
  83. package/lib/aws/compute/authorizers/lambda.js +208 -0
  84. package/lib/aws/compute/base-path-mapping.d.ts +49 -0
  85. package/lib/aws/compute/base-path-mapping.js +52 -0
  86. package/lib/aws/compute/base-scalable-attribute.js +3 -3
  87. package/lib/aws/compute/bastion-host.js +1 -1
  88. package/lib/aws/compute/chain.js +1 -1
  89. package/lib/aws/compute/client-vpn-authorization-rule.js +1 -1
  90. package/lib/aws/compute/client-vpn-endpoint.js +2 -2
  91. package/lib/aws/compute/client-vpn-route.js +2 -2
  92. package/lib/aws/compute/code.d.ts +415 -0
  93. package/lib/aws/compute/code.js +424 -0
  94. package/lib/aws/compute/condition.js +1 -1
  95. package/lib/aws/compute/connections.js +1 -1
  96. package/lib/aws/compute/cors.d.ts +102 -0
  97. package/lib/aws/compute/cors.js +33 -0
  98. package/lib/aws/compute/deployment.d.ts +83 -0
  99. package/lib/aws/compute/deployment.js +158 -0
  100. package/lib/aws/compute/domain-name.d.ts +153 -0
  101. package/lib/aws/compute/domain-name.js +158 -0
  102. package/lib/aws/compute/event-invoke-config.d.ts +2 -2
  103. package/lib/aws/compute/event-invoke-config.js +4 -4
  104. package/lib/aws/compute/event-source-filter.js +2 -2
  105. package/lib/aws/compute/event-source-mapping.d.ts +2 -2
  106. package/lib/aws/compute/event-source-mapping.js +9 -7
  107. package/lib/aws/compute/event-sources/s3-onfailure-destination.js +1 -1
  108. package/lib/aws/compute/event-sources/s3.js +1 -1
  109. package/lib/aws/compute/event-sources/sqs-dlq.js +1 -1
  110. package/lib/aws/compute/event-sources/sqs.js +3 -2
  111. package/lib/aws/compute/fields.js +4 -4
  112. package/lib/aws/compute/function-alias.d.ts +2 -0
  113. package/lib/aws/compute/function-alias.js +14 -2
  114. package/lib/aws/compute/function-base.d.ts +23 -0
  115. package/lib/aws/compute/function-base.js +4 -4
  116. package/lib/aws/compute/function-destinations/event-bridge.js +1 -1
  117. package/lib/aws/compute/function-destinations/function.js +1 -1
  118. package/lib/aws/compute/function-destinations/sqs.js +1 -1
  119. package/lib/aws/compute/function-nodejs/bundling.d.ts +75 -0
  120. package/lib/aws/compute/function-nodejs/bundling.js +405 -0
  121. package/lib/aws/compute/function-nodejs/function.d.ts +99 -0
  122. package/lib/aws/compute/function-nodejs/function.js +175 -0
  123. package/lib/aws/compute/function-nodejs/index.d.ts +2 -0
  124. package/lib/aws/compute/function-nodejs/index.js +19 -0
  125. package/lib/aws/compute/function-nodejs/package-installation.d.ts +8 -0
  126. package/lib/aws/compute/function-nodejs/package-installation.js +36 -0
  127. package/lib/aws/compute/function-nodejs/package-manager.d.ts +33 -0
  128. package/lib/aws/compute/function-nodejs/package-manager.js +99 -0
  129. package/lib/aws/compute/function-nodejs/types.d.ts +410 -0
  130. package/lib/aws/compute/function-nodejs/types.js +81 -0
  131. package/lib/aws/compute/function-nodejs/util.d.ts +60 -0
  132. package/lib/aws/compute/function-nodejs/util.js +202 -0
  133. package/lib/aws/compute/function-url.d.ts +2 -2
  134. package/lib/aws/compute/function-url.js +4 -4
  135. package/lib/aws/compute/function.d.ts +43 -5
  136. package/lib/aws/compute/function.js +106 -18
  137. package/lib/aws/compute/gateway-response.d.ts +157 -0
  138. package/lib/aws/compute/gateway-response.js +156 -0
  139. package/lib/aws/compute/handler.d.ts +10 -0
  140. package/lib/aws/compute/handler.js +20 -0
  141. package/lib/aws/compute/index.d.ts +27 -0
  142. package/lib/aws/compute/index.js +29 -1
  143. package/lib/aws/compute/instance-types.js +1 -1
  144. package/lib/aws/compute/instance.js +1 -1
  145. package/lib/aws/compute/integration.d.ts +311 -0
  146. package/lib/aws/compute/integration.js +165 -0
  147. package/lib/aws/compute/integrations/aws.d.ts +72 -0
  148. package/lib/aws/compute/integrations/aws.js +55 -0
  149. package/lib/aws/compute/integrations/http.d.ts +37 -0
  150. package/lib/aws/compute/integrations/http.js +35 -0
  151. package/lib/aws/compute/integrations/index.d.ts +6 -0
  152. package/lib/aws/compute/integrations/index.js +24 -0
  153. package/lib/aws/compute/integrations/lambda.d.ts +40 -0
  154. package/lib/aws/compute/integrations/lambda.js +73 -0
  155. package/lib/aws/compute/integrations/mock.d.ts +16 -0
  156. package/lib/aws/compute/integrations/mock.js +30 -0
  157. package/lib/aws/compute/integrations/request-context.d.ts +144 -0
  158. package/lib/aws/compute/integrations/request-context.js +3 -0
  159. package/lib/aws/compute/integrations/stepfunctions.d.ts +102 -0
  160. package/lib/aws/compute/integrations/stepfunctions.js +268 -0
  161. package/lib/aws/compute/ip-addresses.js +2 -2
  162. package/lib/aws/compute/ipam.js +1 -1
  163. package/lib/aws/compute/json-schema.d.ts +75 -0
  164. package/lib/aws/compute/json-schema.js +23 -0
  165. package/lib/aws/compute/key-pair.js +1 -1
  166. package/lib/aws/compute/lambda-api.d.ts +46 -0
  167. package/lib/aws/compute/lambda-api.js +64 -0
  168. package/lib/aws/compute/launch-template.js +2 -2
  169. package/lib/aws/compute/lb-shared/base-listener.js +1 -1
  170. package/lib/aws/compute/lb-shared/base-load-balancer.js +2 -2
  171. package/lib/aws/compute/lb-shared/base-target-group.js +1 -1
  172. package/lib/aws/compute/lb-shared/listener-certificate.js +1 -1
  173. package/lib/aws/compute/lb-shared/load-balancer-targets.js +2 -2
  174. package/lib/aws/compute/lb-targets/alb-target.js +3 -3
  175. package/lib/aws/compute/lb-targets/instance-target.js +2 -2
  176. package/lib/aws/compute/lb-targets/ip-target.js +1 -1
  177. package/lib/aws/compute/lb-targets/lambda-target.js +1 -1
  178. package/lib/aws/compute/load-balancer.js +3 -3
  179. package/lib/aws/compute/machine-image/amazon-linux-2022.js +2 -2
  180. package/lib/aws/compute/machine-image/amazon-linux-2023.js +2 -2
  181. package/lib/aws/compute/machine-image/amazon-linux2.js +2 -2
  182. package/lib/aws/compute/machine-image/common.js +1 -1
  183. package/lib/aws/compute/machine-image/machine-image.js +8 -8
  184. package/lib/aws/compute/method.d.ts +219 -0
  185. package/lib/aws/compute/method.js +396 -0
  186. package/lib/aws/compute/methodresponse.d.ts +28 -0
  187. package/lib/aws/compute/methodresponse.js +3 -0
  188. package/lib/aws/compute/model.d.ts +143 -0
  189. package/lib/aws/compute/model.js +141 -0
  190. package/lib/aws/compute/nat.js +5 -5
  191. package/lib/aws/compute/network-acl-types.js +2 -2
  192. package/lib/aws/compute/network-acl.js +3 -3
  193. package/lib/aws/compute/nlb/network-listener-action.js +1 -1
  194. package/lib/aws/compute/nlb/network-listener.js +1 -1
  195. package/lib/aws/compute/nlb/network-load-balancer.js +1 -1
  196. package/lib/aws/compute/nlb/network-target-group.js +1 -1
  197. package/lib/aws/compute/peer.js +1 -1
  198. package/lib/aws/compute/placement-group.js +1 -1
  199. package/lib/aws/compute/port.js +1 -1
  200. package/lib/aws/compute/prefix-list.js +1 -1
  201. package/lib/aws/compute/requestvalidator.d.ts +50 -0
  202. package/lib/aws/compute/requestvalidator.js +59 -0
  203. package/lib/aws/compute/resource.d.ts +223 -0
  204. package/lib/aws/compute/resource.js +316 -0
  205. package/lib/aws/compute/restapi.d.ts +510 -0
  206. package/lib/aws/compute/restapi.js +626 -0
  207. package/lib/aws/compute/route.js +8 -8
  208. package/lib/aws/compute/runtime.d.ts +282 -0
  209. package/lib/aws/compute/runtime.js +337 -0
  210. package/lib/aws/compute/scalable-target.js +3 -3
  211. package/lib/aws/compute/schedule.js +3 -3
  212. package/lib/aws/compute/security-group.js +1 -1
  213. package/lib/aws/compute/stage.d.ts +350 -0
  214. package/lib/aws/compute/stage.js +304 -0
  215. package/lib/aws/compute/state-graph.js +1 -1
  216. package/lib/aws/compute/state-machine-fragment.js +1 -1
  217. package/lib/aws/compute/state-machine.js +4 -4
  218. package/lib/aws/compute/states/choice.js +1 -1
  219. package/lib/aws/compute/states/custom-state.js +1 -1
  220. package/lib/aws/compute/states/distributed-map/item-batcher.js +1 -1
  221. package/lib/aws/compute/states/distributed-map/item-reader.js +5 -5
  222. package/lib/aws/compute/states/distributed-map/result-writer.js +1 -1
  223. package/lib/aws/compute/states/distributed-map.js +1 -1
  224. package/lib/aws/compute/states/fail.js +1 -1
  225. package/lib/aws/compute/states/map-base.js +1 -1
  226. package/lib/aws/compute/states/map.js +1 -1
  227. package/lib/aws/compute/states/parallel.js +1 -1
  228. package/lib/aws/compute/states/pass.js +2 -2
  229. package/lib/aws/compute/states/state.js +1 -1
  230. package/lib/aws/compute/states/succeed.js +1 -1
  231. package/lib/aws/compute/states/task-base.js +2 -2
  232. package/lib/aws/compute/states/task.js +1 -1
  233. package/lib/aws/compute/states/wait.js +2 -2
  234. package/lib/aws/compute/step-scaling-action.js +3 -3
  235. package/lib/aws/compute/step-scaling-policy.js +1 -1
  236. package/lib/aws/compute/stepfunctions-api.d.ts +103 -0
  237. package/lib/aws/compute/stepfunctions-api.js +39 -0
  238. package/lib/aws/compute/subnet-v2.js +2 -2
  239. package/lib/aws/compute/subnet.js +1 -1
  240. package/lib/aws/compute/target-tracking-scaling-policy.js +3 -3
  241. package/lib/aws/compute/task-credentials.js +1 -1
  242. package/lib/aws/compute/task-input.js +1 -1
  243. package/lib/aws/compute/tasks/aws-sdk/call-aws-service.js +1 -1
  244. package/lib/aws/compute/tasks/eventbridge/put-events.js +1 -1
  245. package/lib/aws/compute/tasks/http/invoke.js +1 -1
  246. package/lib/aws/compute/tasks/lambda/invoke.js +1 -1
  247. package/lib/aws/compute/tasks/sqs/send-message.js +1 -1
  248. package/lib/aws/compute/tasks/stepfunctions/invoke-activity.js +1 -1
  249. package/lib/aws/compute/tasks/stepfunctions/start-execution.js +1 -1
  250. package/lib/aws/compute/types.js +1 -1
  251. package/lib/aws/compute/usage-plan.d.ts +194 -0
  252. package/lib/aws/compute/usage-plan.js +174 -0
  253. package/lib/aws/compute/user-data.js +3 -3
  254. package/lib/aws/compute/volume.js +2 -2
  255. package/lib/aws/compute/vpc-endpoint-service.js +1 -1
  256. package/lib/aws/compute/vpc-endpoint.js +6 -6
  257. package/lib/aws/compute/vpc-flow-logs.js +4 -4
  258. package/lib/aws/compute/vpc-link.d.ts +104 -0
  259. package/lib/aws/compute/vpc-link.js +137 -0
  260. package/lib/aws/compute/vpc-v2-base.js +1 -1
  261. package/lib/aws/compute/vpc-v2.js +2 -2
  262. package/lib/aws/compute/vpc.js +4 -4
  263. package/lib/aws/compute/vpn.js +3 -3
  264. package/lib/aws/edge/certificate.js +1 -1
  265. package/lib/aws/edge/distribution.js +3 -3
  266. package/lib/aws/edge/dns-alias-record-targets.js +3 -3
  267. package/lib/aws/edge/dns-record.js +13 -13
  268. package/lib/aws/edge/dns-zone.js +1 -1
  269. package/lib/aws/edge/function.js +2 -2
  270. package/lib/aws/edge/key-value-store.js +4 -4
  271. package/lib/aws/edge/origin.js +3 -3
  272. package/lib/aws/edge/response-headers-policy.js +1 -1
  273. package/lib/aws/encryption/alias.js +1 -1
  274. package/lib/aws/encryption/key.js +1 -1
  275. package/lib/aws/encryption/via-service-principal.js +1 -1
  276. package/lib/aws/iam/grant.js +2 -2
  277. package/lib/aws/iam/group.js +1 -1
  278. package/lib/aws/iam/instance-profile.js +1 -1
  279. package/lib/aws/iam/managed-policy.js +1 -1
  280. package/lib/aws/iam/oidc-provider.js +1 -1
  281. package/lib/aws/iam/policy-document.js +1 -1
  282. package/lib/aws/iam/policy-statement.js +1 -1
  283. package/lib/aws/iam/policy.js +1 -1
  284. package/lib/aws/iam/principals.js +20 -20
  285. package/lib/aws/iam/role.js +1 -1
  286. package/lib/aws/iam/saml-provider.js +2 -2
  287. package/lib/aws/iam/unknown-principal.js +1 -1
  288. package/lib/aws/iam/user.js +5 -5
  289. package/lib/aws/index.d.ts +1 -0
  290. package/lib/aws/index.js +4 -1
  291. package/lib/aws/network/simple-ipv4-vpc.js +1 -1
  292. package/lib/aws/network/subnet-group.js +3 -3
  293. package/lib/aws/network/subnet.js +4 -4
  294. package/lib/aws/notify/archive.js +1 -1
  295. package/lib/aws/notify/connection.js +3 -3
  296. package/lib/aws/notify/event-bus.js +3 -3
  297. package/lib/aws/notify/event-pattern.js +1 -1
  298. package/lib/aws/notify/input.js +2 -2
  299. package/lib/aws/notify/kinesis-stream.js +1 -1
  300. package/lib/aws/notify/notification-rule.d.ts +1 -1
  301. package/lib/aws/notify/notification-rule.js +5 -5
  302. package/lib/aws/notify/policy.js +1 -1
  303. package/lib/aws/notify/queue-policy.js +1 -1
  304. package/lib/aws/notify/queue.js +1 -1
  305. package/lib/aws/notify/resource-policy.js +1 -1
  306. package/lib/aws/notify/rule.js +1 -1
  307. package/lib/aws/notify/schedule.js +1 -1
  308. package/lib/aws/notify/subscription-filter.js +1 -1
  309. package/lib/aws/notify/subscription.js +4 -4
  310. package/lib/aws/notify/subscriptions/email.js +1 -1
  311. package/lib/aws/notify/subscriptions/lambda.js +1 -1
  312. package/lib/aws/notify/subscriptions/sms.js +1 -1
  313. package/lib/aws/notify/subscriptions/sqs.js +1 -1
  314. package/lib/aws/notify/subscriptions/url.js +1 -1
  315. package/lib/aws/notify/targets/event-bus.js +1 -1
  316. package/lib/aws/notify/targets/function.js +1 -1
  317. package/lib/aws/notify/targets/log-group.js +2 -2
  318. package/lib/aws/notify/targets/sqs.js +1 -1
  319. package/lib/aws/notify/targets/state-machine.js +1 -1
  320. package/lib/aws/notify/topic-base.js +1 -1
  321. package/lib/aws/notify/topic.js +6 -5
  322. package/lib/aws/partition.d.ts +21 -0
  323. package/lib/aws/partition.js +42 -0
  324. package/lib/aws/storage/assets/image-asset.d.ts +379 -0
  325. package/lib/aws/storage/assets/image-asset.js +247 -0
  326. package/lib/aws/storage/assets/index.d.ts +2 -0
  327. package/lib/aws/storage/assets/index.js +21 -0
  328. package/lib/aws/storage/assets/s3.d.ts +125 -0
  329. package/lib/aws/storage/assets/s3.js +80 -0
  330. package/lib/aws/storage/auth-token.d.ts +25 -0
  331. package/lib/aws/storage/auth-token.js +54 -0
  332. package/lib/aws/storage/billing.js +1 -1
  333. package/lib/aws/storage/bucket-notifications.js +1 -1
  334. package/lib/aws/storage/bucket-policy.js +1 -1
  335. package/lib/aws/storage/bucket-source.d.ts +1 -1
  336. package/lib/aws/storage/bucket-source.js +4 -4
  337. package/lib/aws/storage/bucket.d.ts +14 -6
  338. package/lib/aws/storage/bucket.js +48 -40
  339. package/lib/aws/storage/capacity.js +1 -1
  340. package/lib/aws/storage/ecr-lifecycle.d.ts +88 -0
  341. package/lib/aws/storage/ecr-lifecycle.js +23 -0
  342. package/lib/aws/storage/ecr-repository.d.ts +446 -0
  343. package/lib/aws/storage/ecr-repository.js +685 -0
  344. package/lib/aws/storage/encryption.js +1 -1
  345. package/lib/aws/storage/index.d.ts +5 -0
  346. package/lib/aws/storage/index.js +10 -3
  347. package/lib/aws/storage/location.d.ts +17 -0
  348. package/lib/aws/storage/location.js +4 -0
  349. package/lib/aws/storage/notification-targets/function.js +1 -1
  350. package/lib/aws/storage/notification-targets/queue.js +1 -1
  351. package/lib/aws/storage/origin-access-identity.js +1 -1
  352. package/lib/aws/storage/parameter.js +2 -2
  353. package/lib/aws/storage/table.js +3 -3
  354. package/lib/aws/storage/util.d.ts +8 -20
  355. package/lib/aws/storage/util.js +56 -34
  356. package/lib/aws/util.d.ts +1 -0
  357. package/lib/aws/util.js +6 -1
  358. package/lib/bundling.d.ts +434 -0
  359. package/lib/bundling.js +368 -0
  360. package/lib/construct-base.js +2 -2
  361. package/lib/duration.js +1 -1
  362. package/lib/expiration.js +1 -1
  363. package/lib/fs/copy.d.ts +2 -0
  364. package/lib/fs/copy.js +57 -0
  365. package/lib/fs/fingerprint.d.ts +21 -0
  366. package/lib/fs/fingerprint.js +165 -0
  367. package/lib/fs/ignore.d.ts +107 -0
  368. package/lib/fs/ignore.js +190 -0
  369. package/lib/fs/index.d.ts +47 -0
  370. package/lib/fs/index.js +88 -0
  371. package/lib/fs/options.d.ts +110 -0
  372. package/lib/fs/options.js +60 -0
  373. package/lib/fs/utils.d.ts +11 -0
  374. package/lib/fs/utils.js +34 -0
  375. package/lib/index.d.ts +5 -0
  376. package/lib/index.js +7 -1
  377. package/lib/private/asset-staging.d.ts +83 -0
  378. package/lib/private/asset-staging.js +205 -0
  379. package/lib/private/cache.d.ts +17 -0
  380. package/lib/private/cache.js +35 -0
  381. package/lib/private/jsii-deprecated.d.ts +2 -0
  382. package/lib/private/jsii-deprecated.js +19 -0
  383. package/lib/private/unique-resource-name.js +3 -2
  384. package/lib/size.js +1 -1
  385. package/lib/stack-base.js +1 -1
  386. package/lib/terra-func.js +2 -2
  387. package/lib/time-zone.js +1 -1
  388. package/node_modules/@balena/dockerignore/CHANGELOG.md +31 -0
  389. package/node_modules/@balena/dockerignore/LICENSE.md +206 -0
  390. package/node_modules/@balena/dockerignore/README.md +261 -0
  391. package/node_modules/@balena/dockerignore/ignore.js +363 -0
  392. package/node_modules/@balena/dockerignore/index.d.ts +45 -0
  393. package/node_modules/@balena/dockerignore/package.json +49 -0
  394. package/node_modules/balanced-match/.github/FUNDING.yml +2 -0
  395. package/node_modules/balanced-match/LICENSE.md +21 -0
  396. package/node_modules/balanced-match/README.md +97 -0
  397. package/node_modules/balanced-match/index.js +62 -0
  398. package/node_modules/balanced-match/package.json +48 -0
  399. package/node_modules/concat-map/.travis.yml +4 -0
  400. package/node_modules/concat-map/LICENSE +18 -0
  401. package/node_modules/concat-map/README.markdown +62 -0
  402. package/node_modules/concat-map/example/map.js +6 -0
  403. package/node_modules/concat-map/index.js +13 -0
  404. package/node_modules/concat-map/package.json +43 -0
  405. package/node_modules/concat-map/test/map.js +39 -0
  406. package/node_modules/ignore/LICENSE-MIT +21 -0
  407. package/node_modules/ignore/README.md +412 -0
  408. package/node_modules/ignore/index.d.ts +61 -0
  409. package/node_modules/ignore/index.js +636 -0
  410. package/node_modules/ignore/legacy.js +559 -0
  411. package/node_modules/ignore/package.json +74 -0
  412. package/node_modules/minimatch/LICENSE +15 -0
  413. package/node_modules/minimatch/README.md +230 -0
  414. package/node_modules/minimatch/minimatch.js +947 -0
  415. package/node_modules/minimatch/node_modules/brace-expansion/LICENSE +21 -0
  416. package/node_modules/minimatch/node_modules/brace-expansion/README.md +129 -0
  417. package/node_modules/minimatch/node_modules/brace-expansion/index.js +201 -0
  418. package/node_modules/minimatch/node_modules/brace-expansion/package.json +47 -0
  419. package/node_modules/minimatch/package.json +33 -0
  420. package/package.json +14 -5
  421. package/lib/aws/compute/function-nodejs.d.ts +0 -55
  422. package/lib/aws/compute/function-nodejs.js +0 -70
@@ -0,0 +1,261 @@
1
+
2
+ # dockerignore
3
+
4
+ `dockerignore` is a file filter library fully compatible with Docker's [.dockerignore
5
+ file](https://docs.docker.com/engine/reference/builder/#dockerignore-file), exposing the
6
+ same API as the popular [ignore](https://github.com/kaelzhang/node-ignore) package for the
7
+ `.gitignore` format.
8
+
9
+ `dockerignore` is also:
10
+
11
+ * Compatible with Linux, macOS and Windows.
12
+ * Compact with 0 external dependencies (production install).
13
+ * A pure Javascript port of Docker's Golang implementation of the `.dockerignore` format.
14
+ * Well tested with hundreds of test cases including comparison against the actual behavior
15
+ of `docker build` on Windows and Linux.
16
+ * Relied on in production environments by
17
+ [balena-cli](https://www.balena.io/docs/reference/balena-cli/),
18
+ [now-cli](https://github.com/zeit/now-cli/)
19
+ and other prominent projects built around Docker.
20
+
21
+ ### What's different from `ignore`?
22
+
23
+ The `.dockerignore` spec has several differences from `.gitignore`:
24
+
25
+ - `*` in `.gitignore` matches everything, whereas in `.dockerignore` it only matches files in the
26
+ current directory (like glob). This difference is important when whitelisting after a `*` rule.
27
+ - `abc` in `.gitignore` matches all `abc` files and directories, however deeply nested, whereas
28
+ in `.dockerignore` it matches only at `./abc` and not in subdirectories like `./somedir/abc`.
29
+ - With `.gitignore`, when a parent directory is ignored, subdirectories cannot be re-added (using
30
+ `!`) since `git` simply avoids walking through the subtree as an optimization. With
31
+ `.dockerignore`, a subdirectory can be re-added even if a parent directory has been ignored.
32
+ - For a complete list of differences, check out the [.gitignore
33
+ spec](https://git-scm.com/docs/gitignore) and the [.dockerignore
34
+ spec](https://docs.docker.com/engine/reference/builder/#dockerignore-file).
35
+
36
+ ### What's the same as `ignore`?
37
+
38
+ The entire API. `dockerignore` started as a fork of
39
+ [node-ignore](https://github.com/kaelzhang/node-ignore), and even reuses the same `index.d.ts` file
40
+ for TypeScript definitions. Under the hood, `node-ignore`'s matching logic was rewritten to closely
41
+ match Docker's implementation (modeled mainly around
42
+ [dockerignore.go](https://github.com/moby/moby/blob/v19.03.8/builder/dockerignore/dockerignore.go)
43
+ and [fileutils.go](https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go)).
44
+
45
+ ### Compatibility
46
+
47
+ `dockerignore` works with Node.js version 8 and above, on Linux, macOS and Windows.
48
+ The code is compiled with [Babel](https://babeljs.io/docs/en/).
49
+
50
+ ## Install
51
+
52
+ ```bash
53
+ npm install --save @balena/dockerignore
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ ```js
59
+ const ignore = require('@balena/dockerignore')
60
+ const ig = ignore().add(['.abc/*', '!.abc/d/'])
61
+ ```
62
+
63
+ Typescript type definitions are also included:
64
+
65
+ ```typescript
66
+ import ignore from '@balena/dockerignore'
67
+ const ig = ignore().add(['.abc/*', '!.abc/d/'])
68
+ ```
69
+
70
+ ### Filter the given paths
71
+
72
+ ```js
73
+ const paths = [
74
+ '.abc/a.js', // filtered out
75
+ '.abc/d/e.js' // included
76
+ ]
77
+
78
+ ig.filter(paths) // ['.abc/d/e.js']
79
+ ig.ignores('.abc/a.js') // true
80
+ ```
81
+
82
+ ### As the filter function
83
+
84
+ ```js
85
+ paths.filter(ig.createFilter()); // ['.abc/d/e.js']
86
+ ```
87
+
88
+ ### Windows paths are supported
89
+
90
+ ```js
91
+ ig.filter(['.abc\\a.js', '.abc\\d\\e.js'])
92
+ // if the code above runs on windows, the result will be
93
+ // ['.abc\\d\\e.js']
94
+ ```
95
+
96
+ ## Backslashes _vs._ forward slashes
97
+
98
+ `dockerignore` behaves just like the Docker CLI ("docker build") in relation to the backslash (`\`)
99
+ and forward slash (`/`) characters:
100
+
101
+ OS | Location | Slash (`/`) | Backslash (`\`)
102
+ ------------ | ----------------------- | ---------------| --------------------
103
+ Linux, macOS | `.dockerignore` | Path separator | Escape character
104
+ Linux, macOS | `filter()`, `ignores()` | Path separator | Part of file name
105
+ Windows | `.dockerignore` | Path separator | Path separator
106
+ Windows | `filter()`, `ignores()` | Path separator | Path separator
107
+
108
+ This means that forward slashes can be used in the `.dockerignore` file for cross-platform
109
+ compatibility. This is consistent with how Windows works generally: both forward slashes
110
+ and backslashes are accepted as path separators by the Command Prompt (cmd.exe) or
111
+ PowerShell, and by library functions like the Golang
112
+ [filepath.Clean](https://golang.org/pkg/path/filepath/#Clean) or the Node.js
113
+ [path.normalize](https://nodejs.org/docs/latest-v10.x/api/path.html#path_path_normalize_path).
114
+
115
+ The use of the backslash as an escape character (Linux and macOS only) is not documented in the
116
+ `.dockerignore` specification. "Reasonable" uses are probably to escape the few characters that
117
+ have a special meaning in the `.dockerignore` file, namely `"*#!\"` (excluding the double quotes),
118
+ as opposed to characters that have a special meaning in [regular
119
+ expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
120
+ generally. The "escaping" behavior for any other characters (e.g. `'\\b'`) is undefined and subject
121
+ to implementation-specific interpretation that may change at any time.
122
+
123
+ ## Absolute paths
124
+
125
+ Leading and trailing slashes (or backslashes on Windows) are removed from `.dockerignore` patterns,
126
+ so `'/a'`, `'a/'` and `'/a/'` are all equivalent to `'a'` in a `.dockerignore` file, and they all
127
+ anchor to the "leftmost" directory when matching against relative paths. For example, pattern `'a'`
128
+ is compared with `'x'` for a given path `'x/y/z'`. This follows Docker's Golang implementation for
129
+ compatibility. Conversely, a given absolute path will not match a non-wildcard pattern. More
130
+ examples:
131
+
132
+ ```js
133
+ ignore().add('a').ignores('a') // true
134
+ ignore().add('/a').ignores('a') // true
135
+ ignore().add('/a/').ignores('a') // true
136
+ ignore().add('a').ignores('/a') // false
137
+ ignore().add('/a').ignores('/a') // false
138
+ ignore().add('/a/').ignores('/a') // false
139
+ ```
140
+
141
+ Considering pattern slash removal, the cases above may be reduced to:
142
+
143
+ ```js
144
+ ignore().add('a').ignores('a') // true
145
+ ignore().add('a').ignores('/a') // false
146
+ ```
147
+
148
+ The 'false' outcome for these examples may appear to mismatch the behavior of "docker build", when
149
+ the source argument for the Dockerfile [ADD](https://docs.docker.com/engine/reference/builder/#add)
150
+ or [COPY](https://docs.docker.com/engine/reference/builder/#copy) instructions is an absolute path
151
+ (starting with a slash). The explanation is that docker converts absolute source paths to relative
152
+ paths (relative to the "build context") **prior to pattern matching:**
153
+ https://github.com/moby/moby/blob/v19.03.8/pkg/archive/archive.go#L806
154
+ https://github.com/moby/moby/blob/v19.03.8/pkg/archive/archive.go#L825
155
+
156
+ ... while `dockerignore` mirrors the implementation of the pattern matcher itself. The advice is
157
+ for your application to do the same as the docker CLI: use relative paths for pattern matching.
158
+ This is also generally more portable across different environments: development machine, CI
159
+ pipelines, servers or end user devices.
160
+
161
+ ## Comments
162
+
163
+ A pattern starting with `'#'` (hash) is ignored as a comment. The hash can be prefixed with
164
+ a slash or backslash in order to match a file name that also starts with a hash:
165
+
166
+ ```js
167
+ ignore().add('#abc').ignores('#abc') // false
168
+ ignore().add('/#abc').ignores('#abc') // true
169
+ ignore().add('\\#abc').ignores('#abc') // true
170
+ ```
171
+
172
+ This works because of the leading slash removal from patterns described in [Absolute
173
+ Paths](#absolute-paths).
174
+
175
+ ## Exclusion patterns
176
+
177
+ Patterns starting with `'!'` (exclamation mark) define matching exclusions (exceptions) as
178
+ documented in the [.dockerignore
179
+ specification](https://docs.docker.com/engine/reference/builder/#dockerignore-file). For
180
+ compatibility with Docker's implementation, patterns starting with `'/!'` or `'!/'` (but not
181
+ `'/!/'`) will also be considered exclusion patterns, in addition to slash removal described in
182
+ [Absolute Paths](#absolute-paths). Backslash escaping as `'\\!'` may be used in order to match a
183
+ file or directory name that starts with the exclamation mark, but this is only possible on Linux
184
+ and macOS, not on Windows. Again, it only behaves this way for compatibility with Docker's
185
+ implementation.
186
+
187
+ ## Options
188
+
189
+ Matching is case-insensitive by default, following the `ignore` API
190
+ ([ignorecase](https://www.npmjs.com/package/ignore#optionsignorecase-since-400)).
191
+ Note however that Docker performs case-sensitive matching.
192
+ Use the `ignorecase: false` option to align with Docker's behavior:
193
+
194
+ ```js
195
+ const ig = ignore({ ignorecase: false }) // for case-sensitive matching
196
+ ```
197
+
198
+ ## Methods
199
+
200
+ ### .add(pattern)
201
+ ### .add(patterns)
202
+
203
+ - **pattern** `String|Ignore` An ignore pattern string, or the `Ignore` instance
204
+ - **patterns** `Array.<pattern>` Array of ignore patterns.
205
+
206
+ Adds a rule or several rules to the current manager.
207
+
208
+ Returns `this`
209
+
210
+ `pattern` could either be a line of ignore pattern or a string of multiple ignore patterns, which means we could just `ignore().add()` the content of a ignore file:
211
+
212
+ ```js
213
+ ignore()
214
+ .add(fs.readFileSync(filenameOfGitignore).toString())
215
+ .filter(filenames)
216
+ ```
217
+
218
+ `pattern` could also be an `ignore` instance, so that we could easily inherit the rules of another `Ignore` instance.
219
+
220
+ ### .ignores(pathname)
221
+
222
+ Returns `Boolean` whether `pathname` should be ignored.
223
+
224
+ ```js
225
+ ig.ignores('.abc/a.js') // true
226
+ ```
227
+
228
+ ### .filter(paths)
229
+
230
+ Filters the given array of pathnames, and returns the filtered array.
231
+
232
+ - **paths** `Array.<path>` The array of `pathname`s to be filtered.
233
+
234
+ ### .createFilter()
235
+
236
+ Creates a filter function which could filter an array of paths with `Array.prototype.filter`.
237
+
238
+ Returns `function(path)` the filter function.
239
+
240
+ ## Contributing
241
+
242
+ Contributions are always welcome!
243
+
244
+ 1. Fork this repository to your own GitHub account and then clone it to your local device.
245
+ 2. Install the dependencies: `npm install`
246
+ 3. Add a test case (if applicable) and ensure it currently fails
247
+ 4. Add code to pass the test
248
+ 5. Make a pull request (additional tests will run on CI to ensure that your test case agrees with an actual `docker build`)
249
+
250
+ ## Acknowledgements
251
+
252
+ The initial work on this project was done by Pranay Prakash
253
+ ([@pranaygp](https://twitter.com/pranaygp)) / [▲ZEIT](https://zeit.co), Kael Zhang
254
+ ([@kaelzhang](https://github.com/kaelzhang)) and the [node-ignore
255
+ contributors](https://github.com/kaelzhang/node-ignore/graphs/contributors).
256
+
257
+ Paulo Castro ([@pdcastro](https://github.com/pdcastro)) / [balena.io](https://www.balena.io/)
258
+ forked the repository in year 2020 ([encouraged by
259
+ Zeit](https://github.com/zeit/dockerignore/pull/16#issuecomment-611790479)) and put in a
260
+ substantial effort on Windows support, cross-platform compatibility and testing, leading to release
261
+ 1.0.0.
@@ -0,0 +1,363 @@
1
+ 'use strict';
2
+ /**
3
+ * @license
4
+ * Copyright 2020 Balena Ltd.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * ------------------------------------------------------------------------
19
+ *
20
+ * Copyright 2018 Zeit, Inc.
21
+ * Licensed under the MIT License. See file LICENSE.md for a full copy.
22
+ *
23
+ * ------------------------------------------------------------------------
24
+ */
25
+
26
+ /**
27
+ * This module implements the [dockerignore
28
+ * spec](https://docs.docker.com/engine/reference/builder/#dockerignore-file),
29
+ * closely following Docker's (Moby) Golang implementation:
30
+ * https://github.com/moby/moby/blob/v19.03.8/builder/dockerignore/dockerignore.go
31
+ * https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go
32
+ * https://github.com/moby/moby/blob/v19.03.8/pkg/archive/archive.go#L825
33
+ *
34
+ * Something the spec is not clear about, but we discovered by reading source code
35
+ * and testing against the "docker build" command, is the handling of backslashes and
36
+ * forward slashes as path separators and escape characters in the .dockerignore file
37
+ * across platforms including Windows, Linux and macOS:
38
+ *
39
+ * * On Linux and macOS, only forward slashes can be used as path separators in the
40
+ * .dockerignore file, and the backslash works as an escape character.
41
+ * * On Windows, both forward slashes and backslashes are allowed as path separators
42
+ * in the .dockerignore file, and the backslash is not used as an escape character.
43
+ *
44
+ * This is consistent with how Windows works generally: both forward slashes and
45
+ * backslashes are accepted as path separators by the cmd.exe Command Prompt or
46
+ * PowerShell, and by library functions like the Golang filepath.Clean or the
47
+ * Node.js path.normalize.
48
+ *
49
+ * Similarly, path strings provided to the IgnoreBase.ignores() and IgnoreBase.filter()
50
+ * methods can use either forward slashes or backslashes as path separators on Windows,
51
+ * but only forward slashes are accepted as path separators on Linux and macOS.
52
+ */
53
+
54
+ const path = require('path');
55
+
56
+ const factory = options => new IgnoreBase(options); // https://github.com/kaelzhang/node-ignore/blob/5.1.4/index.js#L538-L539
57
+ // Fixes typescript module import
58
+
59
+
60
+ factory.default = factory;
61
+ module.exports = factory;
62
+
63
+ function make_array(subject) {
64
+ return Array.isArray(subject) ? subject : [subject];
65
+ }
66
+
67
+ const REGEX_TRAILING_SLASH = /(?<=.)\/$/;
68
+ const REGEX_TRAILING_BACKSLASH = /(?<=.)\\$/;
69
+ const REGEX_TRAILING_PATH_SEP = path.sep === '\\' ? REGEX_TRAILING_BACKSLASH : REGEX_TRAILING_SLASH;
70
+ const KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('dockerignore') : 'dockerignore'; // An implementation of Go's filepath.Clean
71
+ // https://golang.org/pkg/path/filepath/#Clean
72
+ // https://github.com/golang/go/blob/master/src/path/filepath/path.go
73
+ // Note that, like Go, on Windows this function converts forward slashes
74
+ // to backslashes.
75
+
76
+ function cleanPath(file) {
77
+ return path.normalize(file).replace(REGEX_TRAILING_PATH_SEP, '');
78
+ } // Javascript port of Golang's filepath.ToSlash
79
+ // https://golang.org/pkg/path/filepath/#ToSlash
80
+ // https://github.com/golang/go/blob/master/src/path/filepath/path.go
81
+ // Convert any OS-specific path separator to '/'. Backslash is converted
82
+ // to forward slash on Windows, but not on Linux/macOS.
83
+ // Note that both forward slashes and backslashes are valid path separators on
84
+ // Windows. As a result, code such as `pattern.split(path.sep).join('/')` fails
85
+ // on Windows when forward slashes are used as path separators.
86
+
87
+
88
+ function toSlash(file) {
89
+ if (path.sep === '/') {
90
+ return file;
91
+ }
92
+
93
+ return file.replace(/\\/g, '/');
94
+ } // Javascript port of Golang's filepath.FromSlash
95
+ // https://github.com/golang/go/blob/master/src/path/filepath/path.go
96
+
97
+
98
+ function fromSlash(file) {
99
+ if (path.sep === '/') {
100
+ return file;
101
+ }
102
+
103
+ return file.replace(/\//g, path.sep);
104
+ }
105
+
106
+ class IgnoreBase {
107
+ constructor({
108
+ // https://github.com/kaelzhang/node-ignore/blob/5.1.4/index.js#L372
109
+ ignorecase = true
110
+ } = {}) {
111
+ this._rules = [];
112
+ this._ignorecase = ignorecase;
113
+ this[KEY_IGNORE] = true;
114
+
115
+ this._initCache();
116
+ }
117
+
118
+ _initCache() {
119
+ this._cache = {};
120
+ } // @param {Array.<string>|string|Ignore} pattern
121
+
122
+
123
+ add(pattern) {
124
+ this._added = false;
125
+
126
+ if (typeof pattern === 'string') {
127
+ pattern = pattern.split(/\r?\n/g);
128
+ }
129
+
130
+ make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
131
+ // making the behavior changed.
132
+
133
+ if (this._added) {
134
+ this._initCache();
135
+ }
136
+
137
+ return this;
138
+ } // legacy
139
+
140
+
141
+ addPattern(pattern) {
142
+ return this.add(pattern);
143
+ }
144
+
145
+ _addPattern(pattern) {
146
+ // https://github.com/kaelzhang/node-ignore/issues/32
147
+ if (pattern && pattern[KEY_IGNORE]) {
148
+ this._rules = this._rules.concat(pattern._rules);
149
+ this._added = true;
150
+ return;
151
+ }
152
+
153
+ if (this._checkPattern(pattern)) {
154
+ const rule = this._createRule(pattern.trim());
155
+
156
+ if (rule !== null) {
157
+ this._added = true;
158
+
159
+ this._rules.push(rule);
160
+ }
161
+ }
162
+ }
163
+
164
+ _checkPattern(pattern) {
165
+ // https://github.com/moby/moby/blob/v19.03.8/builder/dockerignore/dockerignore.go#L34-L40
166
+ return pattern && typeof pattern === 'string' && pattern.indexOf('#') !== 0 && pattern.trim() !== "";
167
+ }
168
+
169
+ filter(paths) {
170
+ return make_array(paths).filter(path => this._filter(path));
171
+ }
172
+
173
+ createFilter() {
174
+ return path => this._filter(path);
175
+ }
176
+
177
+ ignores(path) {
178
+ return !this._filter(path);
179
+ } // https://github.com/moby/moby/blob/v19.03.8/builder/dockerignore/dockerignore.go#L41-L53
180
+ // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L29-L55
181
+
182
+
183
+ _createRule(pattern) {
184
+ const origin = pattern;
185
+ let negative = false; // > An optional prefix "!" which negates the pattern;
186
+ // https://github.com/moby/moby/blob/v19.03.8/builder/dockerignore/dockerignore.go#L43-L46
187
+
188
+ if (pattern[0] === '!') {
189
+ negative = true;
190
+ pattern = pattern.substring(1).trim();
191
+ } // https://github.com/moby/moby/blob/v19.03.8/builder/dockerignore/dockerignore.go#L47-L53
192
+
193
+
194
+ if (pattern.length > 0) {
195
+ pattern = cleanPath(pattern);
196
+ pattern = toSlash(pattern);
197
+
198
+ if (pattern.length > 1 && pattern[0] === '/') {
199
+ pattern = pattern.slice(1);
200
+ }
201
+ } // https://github.com/moby/moby/blob/v19.03.8/builder/dockerignore/dockerignore.go#L54-L55
202
+
203
+
204
+ if (negative) {
205
+ pattern = '!' + pattern;
206
+ } // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L30
207
+
208
+
209
+ pattern = pattern.trim();
210
+
211
+ if (pattern === "") {
212
+ return null;
213
+ } // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L34
214
+ // convert forward slashes to backslashes on Windows
215
+
216
+
217
+ pattern = cleanPath(pattern); // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L36-L42
218
+
219
+ if (pattern[0] === '!') {
220
+ if (pattern.length === 1) {
221
+ return null;
222
+ }
223
+
224
+ negative = true;
225
+ pattern = pattern.substring(1);
226
+ } else {
227
+ negative = false;
228
+ }
229
+
230
+ return {
231
+ origin,
232
+ pattern,
233
+ // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L54
234
+ dirs: pattern.split(path.sep),
235
+ negative
236
+ };
237
+ } // @returns `Boolean` true if the `path` is NOT ignored
238
+
239
+
240
+ _filter(path) {
241
+ if (!path) {
242
+ return false;
243
+ }
244
+
245
+ if (path in this._cache) {
246
+ return this._cache[path];
247
+ }
248
+
249
+ return this._cache[path] = this._test(path);
250
+ } // @returns {Boolean} true if a file is NOT ignored
251
+ // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L62
252
+
253
+
254
+ _test(file) {
255
+ file = fromSlash(file); // equivalent to golang filepath.Dir() https://golang.org/src/path/filepath/path.go
256
+
257
+ const parentPath = cleanPath(path.dirname(file));
258
+ const parentPathDirs = parentPath.split(path.sep);
259
+ let matched = false;
260
+
261
+ this._rules.forEach(rule => {
262
+ let match = this._match(file, rule); // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L80
263
+
264
+
265
+ if (!match && parentPath !== ".") {
266
+ // Check to see if the pattern matches one of our parent dirs.
267
+ if (rule.dirs.includes('**')) {
268
+ // Ah shucks! We have to test every possible parent path that has
269
+ // a number of dirs _n_ where
270
+ // `rule.dirs.filter(doubleStar).length <= _n_ <= parentPathDirs.length`
271
+ // since the ** can imply any number of directories including 0
272
+ for (let i = rule.dirs.filter(x => x !== '**').length; i <= parentPathDirs.length; i++) {
273
+ match = match || this._match(parentPathDirs.slice(0, i).join(path.sep), rule);
274
+ }
275
+ } else if (rule.dirs.length <= parentPathDirs.length) {
276
+ // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L83
277
+ match = this._match(parentPathDirs.slice(0, rule.dirs.length).join(path.sep), rule);
278
+ }
279
+ }
280
+
281
+ if (match) {
282
+ matched = !rule.negative;
283
+ }
284
+ });
285
+
286
+ return !matched;
287
+ } // @returns {Boolean} true if a file is matched by a rule
288
+
289
+
290
+ _match(file, rule) {
291
+ return this._compile(rule).regexp.test(file);
292
+ } // https://github.com/moby/moby/blob/v19.03.8/pkg/fileutils/fileutils.go#L139
293
+
294
+
295
+ _compile(rule) {
296
+ if (rule.regexp) {
297
+ return rule;
298
+ }
299
+
300
+ let regStr = '^'; // Go through the pattern and convert it to a regexp.
301
+
302
+ let escapedSlash = path.sep === '\\' ? '\\\\' : path.sep;
303
+
304
+ for (let i = 0; i < rule.pattern.length; i++) {
305
+ const ch = rule.pattern[i];
306
+
307
+ if (ch === '*') {
308
+ if (rule.pattern[i + 1] === '*') {
309
+ // is some flavor of "**"
310
+ i++; // Treat **/ as ** so eat the "/"
311
+
312
+ if (rule.pattern[i + 1] === path.sep) {
313
+ i++;
314
+ }
315
+
316
+ if (rule.pattern[i + 1] === undefined) {
317
+ // is "**EOF" - to align with .gitignore just accept all
318
+ regStr += ".*";
319
+ } else {
320
+ // is "**"
321
+ // Note that this allows for any # of /'s (even 0) because
322
+ // the .* will eat everything, even /'s
323
+ regStr += `(.*${escapedSlash})?`;
324
+ }
325
+ } else {
326
+ // is "*" so map it to anything but "/"
327
+ regStr += `[^${escapedSlash}]*`;
328
+ }
329
+ } else if (ch === '?') {
330
+ // "?" is any char except "/"
331
+ regStr += `[^${escapedSlash}]`;
332
+ } else if (ch === '.' || ch === '$') {
333
+ // Escape some regexp special chars that have no meaning
334
+ // in golang's filepath.Match
335
+ regStr += `\\${ch}`;
336
+ } else if (ch === '\\') {
337
+ // escape next char. Note that a trailing \ in the pattern
338
+ // will be left alone (but need to escape it)
339
+ if (path.sep === '\\') {
340
+ // On windows map "\" to "\\", meaning an escaped backslash,
341
+ // and then just continue because filepath.Match on
342
+ // Windows doesn't allow escaping at all
343
+ regStr += escapedSlash;
344
+ continue;
345
+ }
346
+
347
+ if (rule.pattern[i + 1] !== undefined) {
348
+ regStr += '\\' + rule.pattern[i + 1];
349
+ i++;
350
+ } else {
351
+ regStr += '\\';
352
+ }
353
+ } else {
354
+ regStr += ch;
355
+ }
356
+ }
357
+
358
+ regStr += "$";
359
+ rule.regexp = new RegExp(regStr, this._ignorecase ? 'i' : '');
360
+ return rule;
361
+ }
362
+
363
+ }
@@ -0,0 +1,45 @@
1
+ export interface Ignore {
2
+ /**
3
+ * Adds a rule rules to the current manager.
4
+ * @param {string | Ignore} pattern
5
+ * @returns IgnoreBase
6
+ */
7
+ add(pattern: string | Ignore): Ignore
8
+ /**
9
+ * Adds several rules to the current manager.
10
+ * @param {string[]} patterns
11
+ * @returns IgnoreBase
12
+ */
13
+ add(patterns: (string | Ignore)[]): Ignore
14
+
15
+ /**
16
+ * Filters the given array of pathnames, and returns the filtered array.
17
+ * NOTICE that each path here should be a relative path to the root of your repository.
18
+ * @param paths the array of paths to be filtered.
19
+ * @returns The filtered array of paths
20
+ */
21
+ filter(paths: string[]): string[]
22
+ /**
23
+ * Creates a filter function which could filter
24
+ * an array of paths with Array.prototype.filter.
25
+ */
26
+ createFilter(): (path: string) => boolean
27
+
28
+ /**
29
+ * Returns Boolean whether pathname should be ignored.
30
+ * @param {string} pathname a path to check
31
+ * @returns boolean
32
+ */
33
+ ignores(pathname: string): boolean
34
+ }
35
+
36
+ interface Options {
37
+ ignorecase?: boolean
38
+ }
39
+
40
+ /**
41
+ * Creates new ignore manager.
42
+ */
43
+ declare function ignore(options?: Options): Ignore
44
+
45
+ export default ignore