Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): generate gitignore file #758

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cli/src/action/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import * as Table from 'cli-table3';
import { ApplicationConfig, existApplicationConfig, writeApplicationConfig } from "../../config/application"
import * as path from 'node:path'
import * as fs from 'node:fs'
import { FUNCTIONS_DIRECTORY_NAME, GLOBAL_FILE, PACKAGE_FILE, RESPONSE_FILE, TEMPLATE_DIR, TSCONFIG_FILE, TYPE_DIR } from "../../common/constant"

import { FUNCTIONS_DIRECTORY_NAME, GITIGNORE_FILE, GLOBAL_FILE, PACKAGE_FILE, RESPONSE_FILE, TEMPLATE_DIR, TSCONFIG_FILE, TYPE_DIR } from "../../common/constant"
import { ensureDirectory } from "../../util/file"

import { refreshSecretConfig } from "../../config/secret"
import { getEmoji } from "../../util/print";

Expand Down Expand Up @@ -87,6 +89,14 @@ function initFunction() {
const fromTsConfigFile = path.resolve(templateDir, TSCONFIG_FILE)
const outTsConfigFile = path.resolve(process.cwd(), TSCONFIG_FILE)
fs.writeFileSync(outTsConfigFile, fs.readFileSync(fromTsConfigFile, 'utf-8'))

// generate .gitignore
const fromGitIgnoreFile = path.resolve(templateDir, GITIGNORE_FILE)
const outGitIgnoreFile = path.resolve(process.cwd(), GITIGNORE_FILE)
if (!exist(outGitIgnoreFile)) {
fs.writeFileSync(outGitIgnoreFile, fs.readFileSync(fromGitIgnoreFile, 'utf-8'))
}

}

function initPolicy() {
Expand Down
5 changes: 4 additions & 1 deletion cli/src/common/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export const FUNCTIONS_DIRECTORY_NAME = 'functions'
export const FUNCTIONS_CONFIG_FILE_SUFFIX_NAME = '.meta.yaml'
export const COLLECTIONS_DIRECTORY_NAME = 'collections'
export const COLLECTIONS_CONFIG_FILE_SUFFIX_NAME = '.meta.yaml'
export const IGNORE_FILE_NAME = '.gitignore'
export const POLICIES_DIRECTORY_NAME = 'policies'


// token expire time 7 days
export const TOKEN_EXPIRE = 3600 * 24 * 7

Expand All @@ -28,4 +30,5 @@ export const TYPE_DIR = 'types'
export const GLOBAL_FILE = 'global.d.ts'
export const PACKAGE_FILE = 'package.json'
export const RESPONSE_FILE = 'response.d.ts'
export const TSCONFIG_FILE = 'tsconfig.json'
export const TSCONFIG_FILE = 'tsconfig.json'
export const GITIGNORE_FILE = '.gitignore'
5 changes: 5 additions & 0 deletions cli/template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package.json
tsconfig.json
types
node_modules
.secret.yaml