fix(config): switch configuration loading and saving from npmextra.json to smartconfig.json
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 2026-03-24 - 3.3.1 - fix(config)
|
||||
switch configuration loading and saving from npmextra.json to smartconfig.json
|
||||
|
||||
- replace the @push.rocks/npmextra dependency with @push.rocks/smartconfig
|
||||
- update config handling, CLI messaging, and init flow to use smartconfig.json consistently
|
||||
|
||||
## 2026-03-10 - 3.3.0 - feat(server)
|
||||
use UtilityWebsiteServer for dev server, add domain option, update docs, and bump dependencies
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"@git.zone/tsrun": "^2.0.1",
|
||||
"@push.rocks/early": "^4.0.4",
|
||||
"@push.rocks/lik": "^6.3.1",
|
||||
"@push.rocks/npmextra": "^5.3.3",
|
||||
"@push.rocks/smartconfig": "^6.0.0",
|
||||
"@push.rocks/smartcli": "^4.0.20",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartexit": "^2.0.3",
|
||||
|
||||
26
pnpm-lock.yaml
generated
26
pnpm-lock.yaml
generated
@@ -23,12 +23,12 @@ importers:
|
||||
'@push.rocks/lik':
|
||||
specifier: ^6.3.1
|
||||
version: 6.3.1
|
||||
'@push.rocks/npmextra':
|
||||
specifier: ^5.3.3
|
||||
version: 5.3.3
|
||||
'@push.rocks/smartcli':
|
||||
specifier: ^4.0.20
|
||||
version: 4.0.20
|
||||
'@push.rocks/smartconfig':
|
||||
specifier: ^6.0.0
|
||||
version: 6.0.0
|
||||
'@push.rocks/smartdelay':
|
||||
specifier: ^3.0.5
|
||||
version: 3.0.5
|
||||
@@ -1114,6 +1114,9 @@ packages:
|
||||
'@push.rocks/smartclickhouse@2.2.0':
|
||||
resolution: {integrity: sha512-eTzKiREIPSzL1kPkVyD6vEbn+WV/DvQqDjP67VlhNlQGbRcemnJG/eLrUUR1ytmdIqnsZGEK6UYBgyj5nhzLNQ==}
|
||||
|
||||
'@push.rocks/smartconfig@6.0.0':
|
||||
resolution: {integrity: sha512-ohXwJdbDXV2budErnZKWBOz01YkjP6gJsZ7QM9+6Wsh+r7O1CVT3JpV+mD8xJWy5tZRHI+3B9L8z0+WkIDtKzw==}
|
||||
|
||||
'@push.rocks/smartcrypto@2.0.4':
|
||||
resolution: {integrity: sha512-1+/5bsjyataf5uUkUNnnVXGRAt+gHVk1KDzozjTqgqJxHvQk1d9fVDohL6CxUhUucTPtu5VR5xNBiV8YCDuGyw==}
|
||||
|
||||
@@ -6028,6 +6031,23 @@ snapshots:
|
||||
'@push.rocks/smarturl': 3.1.0
|
||||
'@push.rocks/webrequest': 4.0.5
|
||||
|
||||
'@push.rocks/smartconfig@6.0.0':
|
||||
dependencies:
|
||||
'@push.rocks/qenv': 6.1.3
|
||||
'@push.rocks/smartfile': 11.2.7
|
||||
'@push.rocks/smartjson': 5.2.0
|
||||
'@push.rocks/smartlog': 3.2.1
|
||||
'@push.rocks/smartpath': 6.0.0
|
||||
'@push.rocks/smartpromise': 4.2.3
|
||||
'@push.rocks/smartrx': 3.0.10
|
||||
'@push.rocks/taskbuffer': 3.5.0
|
||||
'@tsclass/tsclass': 9.3.0
|
||||
transitivePeerDependencies:
|
||||
- '@nuxt/kit'
|
||||
- react
|
||||
- supports-color
|
||||
- vue
|
||||
|
||||
'@push.rocks/smartcrypto@2.0.4':
|
||||
dependencies:
|
||||
'@push.rocks/smartpromise': 4.2.3
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tswatch',
|
||||
version: '3.3.0',
|
||||
version: '3.3.1',
|
||||
description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.'
|
||||
}
|
||||
|
||||
@@ -119,28 +119,28 @@ const presets: Record<string, interfaces.ITswatchConfig> = {
|
||||
* Handles loading and managing tswatch configuration
|
||||
*/
|
||||
export class ConfigHandler {
|
||||
private npmextra: plugins.npmextra.Npmextra;
|
||||
private smartconfig: plugins.smartconfig.Smartconfig;
|
||||
private cwd: string;
|
||||
|
||||
constructor(cwdArg?: string) {
|
||||
this.cwd = cwdArg || paths.cwd;
|
||||
this.npmextra = new plugins.npmextra.Npmextra(this.cwd);
|
||||
this.smartconfig = new plugins.smartconfig.Smartconfig(this.cwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a tswatch configuration exists
|
||||
*/
|
||||
public hasConfig(): boolean {
|
||||
const config = this.npmextra.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
|
||||
const config = this.smartconfig.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
|
||||
return config !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configuration from npmextra.json
|
||||
* Load configuration from smartconfig.json
|
||||
* If a preset is specified, merge preset defaults with user overrides
|
||||
*/
|
||||
public loadConfig(): interfaces.ITswatchConfig | null {
|
||||
const config = this.npmextra.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
|
||||
const config = this.smartconfig.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
|
||||
|
||||
if (!config) {
|
||||
return null;
|
||||
@@ -177,7 +177,7 @@ export class ConfigHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the config key for npmextra.json
|
||||
* Get the config key for smartconfig.json
|
||||
*/
|
||||
public getConfigKey(): string {
|
||||
return CONFIG_KEY;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { logger } from './tswatch.logging.js';
|
||||
/**
|
||||
* TsWatch - Config-driven file watcher
|
||||
*
|
||||
* Reads configuration from npmextra.json under the key '@git.zone/tswatch'
|
||||
* Reads configuration from smartconfig.json under the key '@git.zone/tswatch'
|
||||
* and sets up watchers, bundles, and dev server accordingly.
|
||||
*/
|
||||
export class TsWatch {
|
||||
@@ -27,7 +27,7 @@ export class TsWatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create TsWatch from npmextra.json configuration
|
||||
* Create TsWatch from smartconfig.json configuration
|
||||
*/
|
||||
public static fromConfig(cwdArg?: string): TsWatch | null {
|
||||
const configHandler = new ConfigHandler(cwdArg);
|
||||
|
||||
@@ -18,7 +18,7 @@ tswatchCli.standardCommand().subscribe(async (argvArg) => {
|
||||
// Config exists - run with it
|
||||
const tsWatch = TsWatch.fromConfig();
|
||||
if (tsWatch) {
|
||||
logger.log('info', 'Starting tswatch with configuration from npmextra.json');
|
||||
logger.log('info', 'Starting tswatch with configuration from smartconfig.json');
|
||||
await tsWatch.start();
|
||||
} else {
|
||||
logger.log('error', 'Failed to load configuration');
|
||||
@@ -26,7 +26,7 @@ tswatchCli.standardCommand().subscribe(async (argvArg) => {
|
||||
}
|
||||
} else {
|
||||
// No config - launch wizard
|
||||
logger.log('info', 'No tswatch configuration found in npmextra.json');
|
||||
logger.log('info', 'No tswatch configuration found in smartconfig.json');
|
||||
const config = await runInit();
|
||||
if (config) {
|
||||
// Run with the newly created config
|
||||
|
||||
@@ -56,10 +56,10 @@ export class TswatchInit {
|
||||
config = { ...preset, preset: template as interfaces.ITswatchConfig['preset'] };
|
||||
}
|
||||
|
||||
// Save to npmextra.json
|
||||
// Save to smartconfig.json
|
||||
await this.saveConfig(config);
|
||||
|
||||
console.log('\nConfiguration saved to npmextra.json');
|
||||
console.log('\nConfiguration saved to smartconfig.json');
|
||||
console.log('Run "tswatch" to start watching.\n');
|
||||
|
||||
return config;
|
||||
@@ -166,16 +166,16 @@ export class TswatchInit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save configuration to npmextra.json
|
||||
* Save configuration to smartconfig.json
|
||||
*/
|
||||
private async saveConfig(config: interfaces.ITswatchConfig): Promise<void> {
|
||||
const npmextraPath = plugins.path.join(paths.cwd, 'npmextra.json');
|
||||
const smartconfigPath = plugins.path.join(paths.cwd, 'smartconfig.json');
|
||||
|
||||
// Read existing npmextra.json if it exists
|
||||
// Read existing smartconfig.json if it exists
|
||||
let existingConfig: Record<string, any> = {};
|
||||
try {
|
||||
const smartfsInstance = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
|
||||
const content = await smartfsInstance.file(npmextraPath).encoding('utf8').read() as string;
|
||||
const content = await smartfsInstance.file(smartconfigPath).encoding('utf8').read() as string;
|
||||
existingConfig = JSON.parse(content);
|
||||
} catch {
|
||||
// File doesn't exist or is invalid, start fresh
|
||||
@@ -186,7 +186,7 @@ export class TswatchInit {
|
||||
|
||||
// Write back
|
||||
const smartfsInstance = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
|
||||
await smartfsInstance.file(npmextraPath).encoding('utf8').write(JSON.stringify(existingConfig, null, 2));
|
||||
await smartfsInstance.file(smartconfigPath).encoding('utf8').write(JSON.stringify(existingConfig, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export { typedserver };
|
||||
|
||||
// @push.rocks scope
|
||||
import * as lik from '@push.rocks/lik';
|
||||
import * as npmextra from '@push.rocks/npmextra';
|
||||
import * as smartconfig from '@push.rocks/smartconfig';
|
||||
import * as smartcli from '@push.rocks/smartcli';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartexit from '@push.rocks/smartexit';
|
||||
@@ -26,7 +26,7 @@ import * as smartwatch from '@push.rocks/smartwatch';
|
||||
|
||||
export {
|
||||
lik,
|
||||
npmextra,
|
||||
smartconfig,
|
||||
smartcli,
|
||||
smartdelay,
|
||||
smartexit,
|
||||
|
||||
Reference in New Issue
Block a user