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: add writing new file before inject if doesn't exist #412

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
61 changes: 60 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,63 @@
## [6.2.11](https://github.com/jondot/hygen/compare/v6.2.10...v6.2.11) (2022-09-07)
## 6.2.11 (2022-10-12)


### Bug Fixes

* add missing CNAME and update root scripts ([c2c1f10](https://github.com/jondot/hygen/commit/c2c1f108d43ab7cecd0e15dc54af2d16e8d35e5c))
* add prism theme ([0e26886](https://github.com/jondot/hygen/commit/0e26886046d225533c6fe865a7fb073854a66ba8))
* align tests ([ffa843f](https://github.com/jondot/hygen/commit/ffa843f9b794777b239dccc1bcd57d6f89055886))
* capitalization from numeric strings breaks template generation ([4e32f5a](https://github.com/jondot/hygen/commit/4e32f5a2ab0c1f06dc56f8c5f0df6259a8ae011e))
* compute path differently ([c9d3d98](https://github.com/jondot/hygen/commit/c9d3d989d8ca878289498f21854c1a672bd04d9a))
* filter subaction only on action-specific folder file names [#192](https://github.com/jondot/hygen/issues/192) ([005100b](https://github.com/jondot/hygen/commit/005100b96071ee1c08449a621dca641850fcb759))
* fix with-prompt generated by hygen init self ([3092de4](https://github.com/jondot/hygen/commit/3092de4a78e73dc369becebdf4adb2a7a22a4ce6))
* handle filesystem sorting, https://github.com/jondot/hygen/issues/93 ([4a293a4](https://github.com/jondot/hygen/commit/4a293a48383828d8622aeac0b067cc6efae9999e))
* make path calculations based on "resolve" for relative paths" ([3638226](https://github.com/jondot/hygen/commit/36382263e6a10ed54494469f102a94779e19f8c2))
* missing dev dependency @types/node ([c500162](https://github.com/jondot/hygen/commit/c5001627ee0d932d5ab5f7c740ac9594eafceaed))
* missing docs/ prefix for links inside .md files ([4049999](https://github.com/jondot/hygen/commit/404999997d787c9f04dcfa1d7044e79f9a0b84dc))
* name variable should be PascalCase [#219](https://github.com/jondot/hygen/issues/219) ([4781e4c](https://github.com/jondot/hygen/commit/4781e4c0f4208e4972acd41bdc2753a2206dc49b))
* prepend should do line 0, not line 1 ([9a8d0be](https://github.com/jondot/hygen/commit/9a8d0be22d9cc55ccb996f1c91ca6e96c68b11bc))
* proper exit code ([a4eb0f3](https://github.com/jondot/hygen/commit/a4eb0f37749256a4f72ece2e1dd59988e00fe133))
* re-enable website push ([2b6cd49](https://github.com/jondot/hygen/commit/2b6cd49181953aa998fe109b53f7e6edefc85069))
* template resolution order ([47640e1](https://github.com/jondot/hygen/commit/47640e1fbed55c628fc9a77e5d6b463c9623780e))
* **config-resolver:** it uses templates from config when explicitly passed ([9f25033](https://github.com/jondot/hygen/commit/9f250330f5cd47cb1b4e9e444bb36bbb8bb6309c))
* **deps:** fix chalk template path ([34e7cea](https://github.com/jondot/hygen/commit/34e7cead9b4c16185362402abb910f157e9cbf0c))
* **docs:** change [[info]] blocks with correct syntax according to docusaurus docs ([5a5d3e7](https://github.com/jondot/hygen/commit/5a5d3e7c25912c04f7638e0d7a25df5cc6fb2e1b))
* re-enable website push ([6e2f918](https://github.com/jondot/hygen/commit/6e2f918f7e5edca3de799130db0a8b898d897a61))
* update color of footer ([9c8a7a8](https://github.com/jondot/hygen/commit/9c8a7a82e854f8844521e2fa82c144bd02622f14))
* update inline code styles ([ca66545](https://github.com/jondot/hygen/commit/ca665453e55af3ceb73104ccf0b8dcedf44e19a2))
* update quick start link ([94bdb97](https://github.com/jondot/hygen/commit/94bdb97872aeb0f64369a0e63939d4944ca2a026))
* update styles ([2f7ed13](https://github.com/jondot/hygen/commit/2f7ed13902fb7eee89b592821ae9fcdf4b32bbcc))
* update title ([127647b](https://github.com/jondot/hygen/commit/127647b47a4c157e18ebd220f63958b4ce118d10))
* use cross platform endlines [#184](https://github.com/jondot/hygen/issues/184) ([10ddb9a](https://github.com/jondot/hygen/commit/10ddb9ab727afc80ec6ef277da86a335f988953b))
* use ultramin theme ([7035d68](https://github.com/jondot/hygen/commit/7035d68330e9bc14c43a540bd0ee5bce8cfc191e))


### Features

* add css and fix homepage hero ([878b4bc](https://github.com/jondot/hygen/commit/878b4bcbe4417927c7eb605af61384e673b7a75c))
* add echobind logo to README ([93dbcdc](https://github.com/jondot/hygen/commit/93dbcdcf6b8889fa3b78e31ba41c8ba82fe6d419))
* add feature component to homepage ([a026b42](https://github.com/jondot/hygen/commit/a026b423d4d66fef82cb1000bf6c64b50d991a19))
* add locals defaults to config ([dbebc1b](https://github.com/jondot/hygen/commit/dbebc1b548df59f2564dcca072bc6abcbc3576c2))
* add path helpers [#198](https://github.com/jondot/hygen/issues/198) ([0f1e68d](https://github.com/jondot/hygen/commit/0f1e68db0318fa9fb2bda66832c5feff02514ece))
* add stories section to homepage ([5aafcbf](https://github.com/jondot/hygen/commit/5aafcbf23aae57f7b382b5b490ec7f2816abfe2d))
* add styled components ([20fb291](https://github.com/jondot/hygen/commit/20fb291e379aa12c97e6a13e6cbe594fb68cf32d))
* cancel generators without showing generator index [#191](https://github.com/jondot/hygen/issues/191) ([9593ef6](https://github.com/jondot/hygen/commit/9593ef6d7a0292ce5fc56c5d0e7c219d23b2328d))
* export hygen VERSION for programmable access [#127](https://github.com/jondot/hygen/issues/127) ([4898a93](https://github.com/jondot/hygen/commit/4898a937567b6c82db20655e52ccdce09509fe30))
* init docusaurus ([559b16f](https://github.com/jondot/hygen/commit/559b16ffa9cc316ff758fc4e0b5b898e409c6e31))
* make frontmatter attributes accessible in body rendering [#214](https://github.com/jondot/hygen/issues/214) ([b38dcc9](https://github.com/jondot/hygen/commit/b38dcc9c2b720db56b7c74210dad16c0932640ba))
* move assets ([620f275](https://github.com/jondot/hygen/commit/620f275a09b585dc1baba43236e362f82f009a5e))
* refactor see how to use section home page ([062774d](https://github.com/jondot/hygen/commit/062774d60ddb491f574ee7b64e7e3410aa36ca0d))
* update deps, improve performance ([84b513b](https://github.com/jondot/hygen/commit/84b513b8ceae8d4985776896514bdd27495711f1))


### Performance Improvements

* replace inquirer with enquirer gains 300ms startup time ([776b336](https://github.com/jondot/hygen/commit/776b3362fcd4a1a69f32fd5fe13c5b06c27cdafa))


### BREAKING CHANGES

* inquirer and enquirer are not 100% compatible. see docs for notes about this



2 changes: 1 addition & 1 deletion dist/ops/inject.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/ops/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
const result_1 = __importDefault(require("./result"));
const injector_1 = __importDefault(require("./injector"));
const injectOp = (action, args, { logger, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
logger.log('inject');
const { attributes: { to, inject }, } = action;
const result = (0, result_1.default)('inject', to);
if (!(inject && to)) {
return result('ignored');
}
const absTo = path_1.default.resolve(cwd, to);
if (!(yield fs_extra_1.default.exists(absTo))) {
logger.err(`Cannot inject to ${to}: doesn't exist.`);
return result('error', {
error: `Cannot inject to ${to}: doesn't exist.`,
});
logger.warn(`${to} doesn't exist, now creating file`);
fs_extra_1.default.ensureFileSync(absTo);
logger.ok(`${to} was successfuly created`);
}
const content = (yield fs_extra_1.default.readFile(absTo)).toString();
const injectResult = (0, injector_1.default)(action, content);
Expand Down
9 changes: 5 additions & 4 deletions src/ops/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const injectOp = async (
args: any,
{ logger, cwd }: RunnerConfig,
): Promise<ActionResult> => {
logger.log('inject')

const {
attributes: { to, inject },
} = action
Expand All @@ -22,10 +24,9 @@ const injectOp = async (
const absTo = path.resolve(cwd, to)

if (!(await fs.exists(absTo))) {
logger.err(`Cannot inject to ${to}: doesn't exist.`)
return result('error', {
error: `Cannot inject to ${to}: doesn't exist.`,
})
logger.warn(`${to} doesn't exist, now creating file`)
fs.ensureFileSync(absTo)
logger.ok(`${to} was successfuly created`)
}

const content = (await fs.readFile(absTo)).toString()
Expand Down