4 Commits

Author SHA1 Message Date
06256f7a4d 0.0.17 2016-07-13 16:06:27 +02:00
be6fc3adfd cleanup after oneself 2016-07-13 16:06:16 +02:00
5ccf5b81e2 0.0.16 2016-07-13 12:09:41 +02:00
d06a2cee2f update sslDir handling 2016-07-13 12:09:34 +02:00
10 changed files with 27 additions and 17 deletions

0
dist/cert.hook.js vendored Normal file → Executable file
View File

View File

@ -3,4 +3,5 @@ export declare let config: string;
export declare let leShConfig: string; export declare let leShConfig: string;
export declare let letsencryptSh: string; export declare let letsencryptSh: string;
export declare let certDir: string; export declare let certDir: string;
export declare let defaultSslDir: string;
export declare let assetDir: string; export declare let assetDir: string;

7
dist/cert.paths.js vendored
View File

@ -6,6 +6,7 @@ exports.config = plugins.path.join(__dirname, "assets/config.json");
exports.leShConfig = plugins.path.join(__dirname, "assets/leshconfig.json"); exports.leShConfig = plugins.path.join(__dirname, "assets/leshconfig.json");
exports.letsencryptSh = plugins.path.join(__dirname, "assets/letsencrypt.sh"); exports.letsencryptSh = plugins.path.join(__dirname, "assets/letsencrypt.sh");
//dirs //dirs
exports.certDir = plugins.path.join(__dirname, "/assets/certs"); exports.certDir = plugins.path.join(__dirname, "assets/certs");
exports.assetDir = plugins.path.join(__dirname, "/assets/"); exports.defaultSslDir = plugins.path.join(__dirname, "assets/defaultSslDir");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2VydC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2NlcnQucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLGdCQUFnQixDQUFDLENBQUE7QUFFMUMsUUFBUTtBQUNHLGdCQUFRLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLGNBQWMsQ0FBQyxDQUFDO0FBQ3ZELGNBQU0sR0FBRyxPQUFPLEN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BTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLHVCQUF1QixDQUFDLENBQUM7QUFFaEYsTUFBTTtBQUNLLGVBQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUMsY0FBYyxDQUFDLENBQUM7QUFDdEQscUJBQWEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUMsc0JBQXNCLENBQUMsQ0FBQztBQUNwRSxnQkFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxTQUFTLENBQUMsQ0FBQyJ9

6
dist/index.d.ts vendored
View File

@ -1,9 +1,9 @@
/// <reference types="q" /> /// <reference types="q" />
import * as plugins from "./cert.plugins"; import * as plugins from "./cert.plugins";
export interface CertConstructorOptions { export interface ICertConstructorOptions {
cfEmail: string; cfEmail: string;
cfKey: string; cfKey: string;
sslDir: string; sslDir?: string;
gitOriginRepo?: string; gitOriginRepo?: string;
testMode?: boolean; testMode?: boolean;
} }
@ -15,7 +15,7 @@ export declare class Cert {
private _testMode; private _testMode;
certificatesPresent: Certificate[]; certificatesPresent: Certificate[];
certificatesValid: Certificate[]; certificatesValid: Certificate[];
constructor(optionsArg: CertConstructorOptions); constructor(optionsArg: ICertConstructorOptions);
sslGitOriginPull: () => void; sslGitOriginPull: () => void;
sslGitOriginAddCommitPush: () => void; sslGitOriginAddCommitPush: () => void;
getDomainCert(domainNameArg: string, optionsArg?: { getDomainCert(domainNameArg: string, optionsArg?: {

6
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "cert", "name": "cert",
"version": "0.0.15", "version": "0.0.17",
"description": "Easily obain SSL certificates from LetsEncrypt. Supports DNS-01 challenge. TypeScript ready.", "description": "Easily obain SSL certificates from LetsEncrypt. Supports DNS-01 challenge. TypeScript ready.",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@ -18,7 +18,7 @@ describe("cert", function () {
}); });
describe("Cert", function () { describe("Cert", function () {
it("should create a new Cert object from class", function () { it("should create a new Cert object from class", function () {
this.timeout(20000); this.timeout(40000);
testCert = new cert.Cert({ testCert = new cert.Cert({
cfEmail: process.env.CF_EMAIL, cfEmail: process.env.CF_EMAIL,
cfKey: process.env.CF_KEY, cfKey: process.env.CF_KEY,
@ -30,7 +30,7 @@ describe("cert", function () {
}); });
it("should get a valid certificate", function (done) { it("should get a valid certificate", function (done) {
this.timeout(120000); this.timeout(120000);
testCert.getDomainCert("hello2.bleu.de").then(function () { testCert.getDomainCert("hello4.bleu.de").then(function () {
done(); done();
}); });
}); });

View File

@ -22,7 +22,7 @@ describe("cert",function(){
}) })
describe("Cert",function(){ describe("Cert",function(){
it("should create a new Cert object from class",function(){ it("should create a new Cert object from class",function(){
this.timeout(20000); this.timeout(40000);
testCert = new cert.Cert({ testCert = new cert.Cert({
cfEmail: process.env.CF_EMAIL, cfEmail: process.env.CF_EMAIL,
cfKey: process.env.CF_KEY, cfKey: process.env.CF_KEY,
@ -34,7 +34,7 @@ describe("cert",function(){
}) })
it("should get a valid certificate",function(done){ it("should get a valid certificate",function(done){
this.timeout(120000); this.timeout(120000);
testCert.getDomainCert("hello2.bleu.de").then(() => { testCert.getDomainCert("hello4.bleu.de").then(() => {
done(); done();
}); });
}) })

View File

@ -7,5 +7,6 @@ export let leShConfig = plugins.path.join(__dirname,"assets/leshconfig.json");
export let letsencryptSh = plugins.path.join(__dirname,"assets/letsencrypt.sh"); export let letsencryptSh = plugins.path.join(__dirname,"assets/letsencrypt.sh");
//dirs //dirs
export let certDir = plugins.path.join(__dirname,"/assets/certs"); export let certDir = plugins.path.join(__dirname,"assets/certs");
export let assetDir = plugins.path.join(__dirname,"/assets/"); export let defaultSslDir = plugins.path.join(__dirname,"assets/defaultSslDir");
export let assetDir = plugins.path.join(__dirname,"assets/");

View File

@ -1,10 +1,10 @@
import * as plugins from "./cert.plugins"; import * as plugins from "./cert.plugins";
import * as paths from "./cert.paths"; import * as paths from "./cert.paths";
export interface CertConstructorOptions { export interface ICertConstructorOptions {
cfEmail: string, cfEmail: string,
cfKey: string, cfKey: string,
sslDir: string, sslDir?: string,
gitOriginRepo?: string, gitOriginRepo?: string,
testMode?: boolean testMode?: boolean
}; };
@ -17,7 +17,7 @@ export class Cert {
private _testMode: boolean private _testMode: boolean
certificatesPresent: Certificate[]; certificatesPresent: Certificate[];
certificatesValid: Certificate[]; certificatesValid: Certificate[];
constructor(optionsArg:CertConstructorOptions) { constructor(optionsArg:ICertConstructorOptions) {
this._cfEmail = optionsArg.cfEmail; this._cfEmail = optionsArg.cfEmail;
this._cfKey = optionsArg.cfKey; this._cfKey = optionsArg.cfKey;
this._sslDir = optionsArg.sslDir; this._sslDir = optionsArg.sslDir;
@ -32,6 +32,8 @@ export class Cert {
JSON.stringify(config), JSON.stringify(config),
plugins.path.join(__dirname, "assets/config.json") plugins.path.join(__dirname, "assets/config.json")
); );
// setup sslDir
if (!this._sslDir) this._sslDir = paths.defaultSslDir;
// setup Git // setup Git
if (this._gitOriginRepo) { if (this._gitOriginRepo) {
plugins.smartgit.init(this._sslDir); plugins.smartgit.init(this._sslDir);
@ -75,6 +77,7 @@ export class Cert {
let fetchedCertsArray: string[] = plugins.smartfile.fs.listFoldersSync(paths.certDir); let fetchedCertsArray: string[] = plugins.smartfile.fs.listFoldersSync(paths.certDir);
if (fetchedCertsArray.indexOf(domainNameArg) != -1) { if (fetchedCertsArray.indexOf(domainNameArg) != -1) {
updateSslDirSync(this._sslDir, domainNameArg); updateSslDirSync(this._sslDir, domainNameArg);
plugins.smartfile.fs.removeSync(plugins.path.join(paths.certDir,domainNameArg));
} }
this.sslGitOriginAddCommitPush(); this.sslGitOriginAddCommitPush();
done.resolve(); done.resolve();