-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
131 additions
and
5 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,44 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## [5.1.0] | ||
|
||
### Added | ||
|
||
- `CHANGELOG.md` file is not present and can be used. | ||
- script completion file is installed on program run, and the install bash is reloading the SHELL. | ||
|
||
### Change | ||
|
||
- | ||
|
||
### Fixed | ||
|
||
- | ||
|
||
## [5.0.1] | ||
|
||
### Added | ||
|
||
- (internal) Make it work on the Crystallize Staging environement | ||
|
||
## [5.0.0] | ||
|
||
This is the new version that will live in the future, built on top of Bun.js it is shipped through Github and does not require anything on the user side. | ||
|
||
### Added | ||
|
||
- `login` command to save your credentials `~/.crystallize/credentials.json`. | ||
- `whoami` tells you who is logged-in via `~/.crystallize/credentials.json`. | ||
- (wip) `install-boilerplate` to install boilerplates. | ||
- `run-mass-operation` to run Mass Operation files. | ||
|
||
## [4.x] | ||
|
||
The 4.x version called `@crystallize/cli-next`, hosted in NPMJS is now deprecated, it was mainly used to install boilerplates, dump and import | ||
tenant data. It was using `@crystallize/import-utilities` which is now deprecated in favor of Mass Operation | ||
|
||
## [3.x] | ||
|
||
The 3.x version called `@crystallize/cli`, hosted in NPMJS is now deprecated, it was mainly used to install old-legacy boilerplates |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
_crystallize_completions() { | ||
local cur="${COMP_WORDS[COMP_CWORD]}" | ||
local cmd="${COMP_WORDS[1]}" | ||
local subcmd="${COMP_WORDS[2]}" | ||
local subsubcmd="${COMP_WORDS[3]}" | ||
|
||
local commands="help install-boilerplate login whoami run-mass-operation" | ||
local program_options="--version" | ||
local default_options="--help" | ||
|
||
COMPREPLY=() | ||
|
||
case "${cmd}" in | ||
login) | ||
local options="${default_options}" | ||
COMPREPLY=($(compgen -W "${options}" -- "${cur}")) | ||
return 0 | ||
;; | ||
install-boilerplate) | ||
local options="${default_options} --bootstrap-tenant" | ||
COMPREPLY=($(compgen -W "${options}" -- "${cur}")) | ||
return 0 | ||
;; | ||
run-mass-operation) | ||
local options="${default_options} --token_id= --token_secret= --legacy-spec" | ||
COMPREPLY=($(compgen -W "${options}" -- "${cur}")) | ||
return 0 | ||
;; | ||
esac | ||
|
||
if [[ "${COMP_CWORD}" -eq 1 ]]; then | ||
COMPREPLY=($(compgen -W "${commands} ${program_options} ${default_options}" -- "${cur}")) | ||
fi | ||
} | ||
|
||
complete -F _crystallize_completions crystallize |
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,37 @@ | ||
import os from 'os'; | ||
import type { Logger } from '../contracts/logger'; | ||
//@ts-expect-error - This is a workaround to import the completion file as text. It's working with bun. | ||
import Completion from '../../content/completion_file.bash' with { type: 'text' }; | ||
|
||
type Deps = { | ||
logger: Logger; | ||
}; | ||
export const installCompletion = async (shell: string, { logger }: Deps): Promise<void> => { | ||
const shellName = shell.split('/').pop(); | ||
let rcFile; | ||
if (shellName === 'bash') { | ||
rcFile = `${os.homedir()}/.bashrc`; | ||
} else if (shellName === 'zsh') { | ||
rcFile = `${os.homedir()}/.zshrc`; | ||
} else { | ||
logger.warn(`Unsupported shell: ${shellName}. Completion file was not installed.`); | ||
return; | ||
} | ||
const dest = `${os.homedir()}/.crystallize/completion_file`; | ||
const fileRc = Bun.file(rcFile); | ||
if (!fileRc.exists()) { | ||
logger.warn(`The rc file ${rcFile} does not exist. Completion file was not installed.`); | ||
return; | ||
} | ||
|
||
const completionLine = `[ -s "${dest}" ] && source "${dest}"`; | ||
const fileContent = await fileRc.text(); | ||
// we always write the new completion | ||
await Bun.write(dest, Completion); | ||
if (fileContent.includes(completionLine)) { | ||
logger.debug(`Completion is already set up in ${rcFile}`); | ||
return; | ||
} | ||
await Bun.write(rcFile, `${fileContent}# Crystallize CLI completion\n${completionLine}\n`); | ||
logger.success(`Installing completion file in ${rcFile}`); | ||
}; |
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