Skip to content

Commit

Permalink
refactor: Env module
Browse files Browse the repository at this point in the history
  • Loading branch information
philcockfield committed Nov 27, 2024
1 parent a7237cb commit 68c5b47
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/**
* TODO 🐷
*/
export {};
1 change: 0 additions & 1 deletion code/sys.driver/driver-vitepress/src/-tmpl/mod.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { Tmpl } from './m.Tmpl.ts';
export { ensureFiles } from './u.ensureFiles.ts';
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { c, describe, expect, Fs, it } from '../-test.ts';
import { assertEnvExists, SAMPLE } from './-u.ts';
import { Env } from './m.Env.ts';
import { VitePress } from './mod.ts';
import { VitePress } from '../mod.ts';

describe('Vitepress.Env', () => {
it('API', () => {
Expand Down
25 changes: 25 additions & 0 deletions code/sys.driver/driver-vitepress/src/m.Env/-u.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { type t, expect } from '../-test.ts';
import { Fs } from './common.ts';
export { SAMPLE } from '../m.VitePress/-u.ts';

/**
* Assert the given path exists.
*/
export const assertExists = async (path: t.StringPath, expected = true) => {
expect(await Fs.exists(path)).to.eql(expected, path);
};

/**
* Assert all the standard environment paths exists in the given directory.
*/
export const assertEnvExists = async (dir: t.StringDir, expected = true) => {
const assert = (path: string) => assertExists(Fs.join(dir, path), expected);
await assert('.vscode/settings.json');
await assert('.gitignore');
await assert('.vitepress/config.ts');
await assert('.sys/-main.ts');
await assert('deno.json');
await assert('package.json');
await assert('pkg.ts');
await assert('docs/index.md');
};
19 changes: 19 additions & 0 deletions code/sys.driver/driver-vitepress/src/m.Env/m.Env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { type t, c } from './common.ts';
import { ensureFiles } from './u.ensureFiles.ts';

/**
* Helpers for establishing and updating the project environment.
*/
export const Env: t.VitePressEnvLib = {
/**
* Initialize template files.
*/
async init(args = {}) {
const { inDir = '', srcDir, force = false, silent = false, filter } = args;
const files = await ensureFiles({ inDir, srcDir, force, filter });
if (!silent) {
console.info(c.green('Update Environment'));
files.table.render();
}
},
};
1 change: 1 addition & 0 deletions code/sys.driver/driver-vitepress/src/m.Env/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Env } from './m.Env.ts';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tmpl } from '../-tmpl/mod.ts';
import { type t, Cli, Fs, c, pkg } from './common.ts';
import { Tmpl } from './m.Tmpl.ts';

/**
* Ensure the required configuration files exist within
Expand Down
3 changes: 2 additions & 1 deletion code/sys.driver/driver-vitepress/src/m.VitePress/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { ViteLog } from '@sys/driver-vite/log';
export { Tmpl, ensureFiles } from '../-tmpl/mod.ts';
export { Tmpl } from '../-tmpl/mod.ts';
export { Env } from '../m.Env/mod.ts';

export * from '../common.ts';
9 changes: 0 additions & 9 deletions code/sys.driver/driver-vitepress/src/m.VitePress/m.Env.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { t } from './common.ts';
import { Env } from './m.Env.ts';

import { Env } from '../m.Env/mod.ts';
import { build } from './u.cmd.build.ts';
import { dev } from './u.cmd.dev.ts';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type t, Cmd, Cli, Fs, Pkg, Time, c } from './common.ts';
import { Env } from './m.Env.ts';
import { type t, c, Cli, Cmd, Env, Fs, Pkg, Time } from './common.ts';
import { Log } from './u.log.ts';

type B = t.VitePressLib['build'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Cmd, Net, type t } from './common.ts';
import { Env } from './m.Env.ts';
import { type t, Cmd, Env, Net } from './common.ts';
import { keyboardFactory } from './u.keyboard.ts';
import { Log } from './u.log.ts';

Expand Down
12 changes: 0 additions & 12 deletions code/sys.driver/driver-vitepress/src/m.VitePress/u.initEnv.ts

This file was deleted.

2 changes: 1 addition & 1 deletion code/sys.driver/driver-vitepress/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* Module types.
*/
export type * from './-cmd/t.ts';
export type * from './m.Config/t.ts';
export type * from './m.Env/t.ts';
export type * from './m.VitePress/t.ts';

0 comments on commit 68c5b47

Please sign in to comment.