-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
126 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {AppendToDockerignoreService} from '../services/append-to-dockerignore-service' | ||
import {AppendToGitignoreService} from '../services/append-to-gitignore-service' | ||
import {AppendToNpmignoreService} from '../services/append-to-npmignore-service' | ||
import {AppendToVercelignoreService} from '../services/append-to-vercelignore-service' | ||
|
||
class AppendToIgnoreService { | ||
async run (): Promise<void> { | ||
new AppendToDockerignoreService().run() | ||
new AppendToGitignoreService().run() | ||
new AppendToNpmignoreService().run() | ||
new AppendToVercelignoreService().run() | ||
} | ||
} | ||
|
||
export {AppendToIgnoreService} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import {existsSync, writeFileSync, readFileSync, appendFileSync} from 'fs' | ||
|
||
class AppendToVercelignoreService { | ||
get vercelignore(): string { | ||
return '.vercelignore' | ||
} | ||
|
||
get envFormat(): string { | ||
return '.env*' // asterisk | ||
} | ||
|
||
get flaskenvFormat(): string { | ||
return '.flaskenv*' | ||
} | ||
|
||
get envProjectFormat(): string { | ||
return '!.env.project' | ||
} | ||
|
||
get envVaultFormat(): string { | ||
return '!.env.vault' | ||
} | ||
|
||
missing(): boolean { | ||
return !existsSync(this.vercelignore) | ||
} | ||
|
||
append(str: string): void { | ||
appendFileSync(this.vercelignore, str) | ||
} | ||
|
||
touch(): void { | ||
writeFileSync(this.vercelignore, '') | ||
} | ||
|
||
read(): string { | ||
return readFileSync(this.vercelignore, 'utf8') | ||
} | ||
|
||
async run(): Promise<void> { | ||
let envExists = false | ||
let flaskenvExists = false | ||
let envProjectExists = false | ||
let envVaultExists = false | ||
|
||
if (this.missing()) { | ||
// ignore. must not be a vercel project | ||
} else { | ||
// 2. iterate over vercelignore lines | ||
const lines = this.read().split(/\r?\n/) | ||
|
||
// 3. for each line check if ignore already exists | ||
for (const line of lines) { | ||
const trimLine = line.trim() | ||
|
||
if (trimLine === this.envFormat) { | ||
envExists = true | ||
} | ||
|
||
if (trimLine === this.flaskenvFormat) { | ||
flaskenvExists = true | ||
} | ||
|
||
if (trimLine === this.envProjectFormat) { | ||
envProjectExists = true | ||
} | ||
|
||
if (trimLine === this.envVaultFormat) { | ||
envVaultExists = true | ||
} | ||
} | ||
|
||
// 4. add ignore if it does not already exist | ||
if (envExists === false) { | ||
this.append('\n' + this.envFormat) | ||
} | ||
|
||
if (flaskenvExists === false) { | ||
this.append('\n' + this.flaskenvFormat) | ||
} | ||
|
||
if (envProjectExists === false) { | ||
this.append('\n' + this.envProjectFormat) | ||
} | ||
|
||
if (envVaultExists === false) { | ||
this.append('\n' + this.envVaultFormat) | ||
} | ||
} | ||
} | ||
} | ||
|
||
export {AppendToVercelignoreService} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters