@cloud-cli/le 1.1.4 → 1.2.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.
package/README.md
CHANGED
|
@@ -11,10 +11,10 @@ Requires `certbot` to be installed on server and properly configured for Let's E
|
|
|
11
11
|
cy le.add --domain example.com
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
**Update a certificate with domain example.com and
|
|
14
|
+
**Update a certificate with domain example.com and subdomains**
|
|
15
15
|
|
|
16
16
|
```
|
|
17
|
-
cy le.add --
|
|
17
|
+
cy le.add --domains example.com,foo.example.com --useWildcard true --update
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
**Remove a certificate**
|
|
@@ -5,6 +5,7 @@ export interface Certificate {
|
|
|
5
5
|
}
|
|
6
6
|
export interface CertificateOptions {
|
|
7
7
|
domain: string;
|
|
8
|
+
domains?: string;
|
|
8
9
|
}
|
|
9
10
|
export interface CreateCertificateOptions extends CertificateOptions {
|
|
10
11
|
useWildcard: boolean;
|
|
@@ -14,7 +15,7 @@ export interface CreateCertificateOptions extends CertificateOptions {
|
|
|
14
15
|
export declare class CertificateManager {
|
|
15
16
|
private readonly domainPattern;
|
|
16
17
|
certificateExists({ domain }: CertificateOptions): boolean;
|
|
17
|
-
createCertificate({ domain, useWildcard, additionalOptions, update }: CreateCertificateOptions): true | Promise<string>;
|
|
18
|
+
createCertificate({ domain, domains, useWildcard, additionalOptions, update }: CreateCertificateOptions): true | Promise<string>;
|
|
18
19
|
removeCertificate({ domain }: CertificateOptions): boolean;
|
|
19
20
|
getCertificateList(): string[];
|
|
20
21
|
getCertificate({ domain }: CertificateOptions): Promise<string>;
|
|
@@ -12,16 +12,19 @@ export class CertificateManager {
|
|
|
12
12
|
}
|
|
13
13
|
return existsSync(join(certificatesFolder, domain));
|
|
14
14
|
}
|
|
15
|
-
createCertificate({ domain, useWildcard, additionalOptions, update }) {
|
|
16
|
-
if (!this.isValidDomain(domain)) {
|
|
17
|
-
throw new Error('Invalid domain: ' + domain);
|
|
18
|
-
}
|
|
15
|
+
createCertificate({ domain, domains, useWildcard, additionalOptions, update }) {
|
|
19
16
|
const path = join(certificatesFolder, domain);
|
|
20
17
|
if (existsSync(path) && !update) {
|
|
21
18
|
return true;
|
|
22
19
|
}
|
|
23
|
-
const
|
|
24
|
-
const
|
|
20
|
+
const listOfDomains = domains ? domains.split(',').map(s => s.trim()) : [domain];
|
|
21
|
+
for (const d of listOfDomains) {
|
|
22
|
+
if (!this.isValidDomain(d)) {
|
|
23
|
+
throw new Error('Invalid domain: ' + d);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const domainsWithStar = !useWildcard ? listOfDomains : listOfDomains.flatMap(d => [d, '*.' + d]);
|
|
27
|
+
const domainsWithPrefix = domainsWithStar.flatMap((domain) => ['-d', domain]);
|
|
25
28
|
const out = sh('certbot', ['certonly', ...(additionalOptions || []), ...domainsWithPrefix]);
|
|
26
29
|
const stdout = String(out.stdout || '');
|
|
27
30
|
const stderr = String(out.stderr || '').split('\n').map(s => '! ' + s).join('\n');
|