@mapples/cli 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/assets.d.ts +2 -2
- package/dist/commands/global.d.ts +2 -2
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/pages.d.ts +2 -2
- package/dist/commands/style.d.ts +2 -2
- package/dist/index.js +77 -45
- package/dist/index.js.map +1 -1
- package/dist/utils/config.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const syncAssets: () => Promise<void>;
|
|
2
|
-
export declare const showAssetsInfo: () => Promise<void>;
|
|
1
|
+
export declare const syncAssets: (configPath?: string) => Promise<void>;
|
|
2
|
+
export declare const showAssetsInfo: (configPath?: string) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const globalSync: () => Promise<void>;
|
|
2
|
-
export declare const globalInfo: () => Promise<void>;
|
|
1
|
+
export declare const globalSync: (configPath?: string) => Promise<void>;
|
|
2
|
+
export declare const globalInfo: (configPath?: string) => Promise<void>;
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const initProject: () => Promise<void>;
|
|
1
|
+
export declare const initProject: (configPath?: string) => Promise<void>;
|
package/dist/commands/pages.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const syncPages: () => Promise<void>;
|
|
2
|
-
export declare const showPagesInfo: () => Promise<void>;
|
|
1
|
+
export declare const syncPages: (configPath?: string) => Promise<void>;
|
|
2
|
+
export declare const showPagesInfo: (configPath?: string) => Promise<void>;
|
package/dist/commands/style.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const syncStyle: () => Promise<void>;
|
|
2
|
-
export declare const showStyleInfo: () => Promise<void>;
|
|
1
|
+
export declare const syncStyle: (configPath?: string) => Promise<void>;
|
|
2
|
+
export declare const showStyleInfo: (configPath?: string) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -50251,10 +50251,34 @@ const DEFAULT_CONFIG = {
|
|
|
50251
50251
|
},
|
|
50252
50252
|
};
|
|
50253
50253
|
const CONFIG_FILE_PATH = '.mapplesrc.json';
|
|
50254
|
-
const
|
|
50254
|
+
const findConfigFile = (startPath = process.cwd()) => {
|
|
50255
|
+
let currentPath = path.resolve(startPath);
|
|
50256
|
+
while (currentPath !== path.dirname(currentPath)) {
|
|
50257
|
+
const configPath = path.join(currentPath, CONFIG_FILE_PATH);
|
|
50258
|
+
if (fs.existsSync(configPath)) {
|
|
50259
|
+
return configPath;
|
|
50260
|
+
}
|
|
50261
|
+
currentPath = path.dirname(currentPath);
|
|
50262
|
+
}
|
|
50263
|
+
return null;
|
|
50264
|
+
};
|
|
50265
|
+
const readConfig = (configPath) => {
|
|
50255
50266
|
try {
|
|
50256
|
-
|
|
50257
|
-
|
|
50267
|
+
let filePath;
|
|
50268
|
+
if (configPath) {
|
|
50269
|
+
// Use the provided path
|
|
50270
|
+
filePath = path.resolve(configPath);
|
|
50271
|
+
}
|
|
50272
|
+
else {
|
|
50273
|
+
// Search for the config file up the directory tree
|
|
50274
|
+
const foundPath = findConfigFile();
|
|
50275
|
+
if (!foundPath) {
|
|
50276
|
+
return null;
|
|
50277
|
+
}
|
|
50278
|
+
filePath = foundPath;
|
|
50279
|
+
}
|
|
50280
|
+
if (fs.existsSync(filePath)) {
|
|
50281
|
+
const configData = fs.readFileSync(filePath, 'utf-8');
|
|
50258
50282
|
return JSON.parse(configData);
|
|
50259
50283
|
}
|
|
50260
50284
|
return null;
|
|
@@ -50264,9 +50288,10 @@ const readConfig = () => {
|
|
|
50264
50288
|
return null;
|
|
50265
50289
|
}
|
|
50266
50290
|
};
|
|
50267
|
-
const writeConfig = (config) => {
|
|
50268
|
-
|
|
50269
|
-
|
|
50291
|
+
const writeConfig = (config, configPath) => {
|
|
50292
|
+
const filePath = configPath || CONFIG_FILE_PATH;
|
|
50293
|
+
writeJsonToFile(filePath, config);
|
|
50294
|
+
console.log(`Configuration written to ${filePath}`);
|
|
50270
50295
|
};
|
|
50271
50296
|
const updateGitignore = () => {
|
|
50272
50297
|
const gitignorePath = '.gitignore';
|
|
@@ -75352,9 +75377,9 @@ const createPageFromTemplates = (pageName, pageData, config) => {
|
|
|
75352
75377
|
});
|
|
75353
75378
|
console.log(`Created page: ${pageName}`);
|
|
75354
75379
|
};
|
|
75355
|
-
const syncPages = async () => {
|
|
75380
|
+
const syncPages = async (configPath) => {
|
|
75356
75381
|
try {
|
|
75357
|
-
const config = readConfig();
|
|
75382
|
+
const config = readConfig(configPath);
|
|
75358
75383
|
if (!config) {
|
|
75359
75384
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75360
75385
|
process.exit(1);
|
|
@@ -75372,10 +75397,10 @@ const syncPages = async () => {
|
|
|
75372
75397
|
process.exit(1);
|
|
75373
75398
|
}
|
|
75374
75399
|
};
|
|
75375
|
-
const showPagesInfo = async () => {
|
|
75400
|
+
const showPagesInfo = async (configPath) => {
|
|
75376
75401
|
try {
|
|
75377
75402
|
console.log('Fetching pages...');
|
|
75378
|
-
const config = readConfig();
|
|
75403
|
+
const config = readConfig(configPath);
|
|
75379
75404
|
if (!config) {
|
|
75380
75405
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75381
75406
|
process.exit(1);
|
|
@@ -75461,9 +75486,9 @@ const createDonotEditFile = (styleDir) => {
|
|
|
75461
75486
|
fs.writeFileSync(donotEditPath, '');
|
|
75462
75487
|
}
|
|
75463
75488
|
};
|
|
75464
|
-
const syncStyle = async () => {
|
|
75489
|
+
const syncStyle = async (configPath) => {
|
|
75465
75490
|
try {
|
|
75466
|
-
const config = readConfig();
|
|
75491
|
+
const config = readConfig(configPath);
|
|
75467
75492
|
if (!config) {
|
|
75468
75493
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75469
75494
|
process.exit(1);
|
|
@@ -75499,10 +75524,10 @@ const syncStyle = async () => {
|
|
|
75499
75524
|
process.exit(1);
|
|
75500
75525
|
}
|
|
75501
75526
|
};
|
|
75502
|
-
const showStyleInfo = async () => {
|
|
75527
|
+
const showStyleInfo = async (configPath) => {
|
|
75503
75528
|
try {
|
|
75504
75529
|
console.log('Fetching style...');
|
|
75505
|
-
const config = readConfig();
|
|
75530
|
+
const config = readConfig(configPath);
|
|
75506
75531
|
if (!config) {
|
|
75507
75532
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75508
75533
|
process.exit(1);
|
|
@@ -75650,9 +75675,9 @@ const getExistingMetaFiles = (config) => {
|
|
|
75650
75675
|
}
|
|
75651
75676
|
return existingFiles;
|
|
75652
75677
|
};
|
|
75653
|
-
const syncAssets = async () => {
|
|
75678
|
+
const syncAssets = async (configPath) => {
|
|
75654
75679
|
try {
|
|
75655
|
-
const config = readConfig();
|
|
75680
|
+
const config = readConfig(configPath);
|
|
75656
75681
|
if (!config) {
|
|
75657
75682
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75658
75683
|
process.exit(1);
|
|
@@ -75735,10 +75760,10 @@ const syncAssets = async () => {
|
|
|
75735
75760
|
process.exit(1);
|
|
75736
75761
|
}
|
|
75737
75762
|
};
|
|
75738
|
-
const showAssetsInfo = async () => {
|
|
75763
|
+
const showAssetsInfo = async (configPath) => {
|
|
75739
75764
|
try {
|
|
75740
75765
|
console.log('Fetching assets...');
|
|
75741
|
-
const config = readConfig();
|
|
75766
|
+
const config = readConfig(configPath);
|
|
75742
75767
|
if (!config) {
|
|
75743
75768
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75744
75769
|
process.exit(1);
|
|
@@ -75925,9 +75950,9 @@ const executeSyncOperations$1 = async (syncOptions) => {
|
|
|
75925
75950
|
await Promise.all(syncPromises);
|
|
75926
75951
|
console.log('Sync operations completed successfully!');
|
|
75927
75952
|
};
|
|
75928
|
-
const initProject = async () => {
|
|
75953
|
+
const initProject = async (configPath) => {
|
|
75929
75954
|
try {
|
|
75930
|
-
const existingConfig = readConfig();
|
|
75955
|
+
const existingConfig = readConfig(configPath);
|
|
75931
75956
|
if (existingConfig) {
|
|
75932
75957
|
console.log('Updating existing Mapples project configuration...');
|
|
75933
75958
|
}
|
|
@@ -75935,7 +75960,7 @@ const initProject = async () => {
|
|
|
75935
75960
|
console.log('Initializing Mapples project...');
|
|
75936
75961
|
}
|
|
75937
75962
|
const config = await promptForConfig();
|
|
75938
|
-
writeConfig(config);
|
|
75963
|
+
writeConfig(config, configPath);
|
|
75939
75964
|
updateGitignore();
|
|
75940
75965
|
console.log('Project initialization completed successfully');
|
|
75941
75966
|
const { installPackages } = await inquirer.prompt([
|
|
@@ -75996,20 +76021,20 @@ const promptForComponentSelection = async () => {
|
|
|
75996
76021
|
}
|
|
75997
76022
|
return selectedComponents;
|
|
75998
76023
|
};
|
|
75999
|
-
const executeSyncOperations = async (components) => {
|
|
76024
|
+
const executeSyncOperations = async (components, configPath) => {
|
|
76000
76025
|
console.log('\nStarting sync operations...');
|
|
76001
76026
|
const syncPromises = [];
|
|
76002
76027
|
if (components.includes('pages')) {
|
|
76003
76028
|
console.log('Syncing pages...');
|
|
76004
|
-
syncPromises.push(syncPages());
|
|
76029
|
+
syncPromises.push(syncPages(configPath));
|
|
76005
76030
|
}
|
|
76006
76031
|
if (components.includes('style')) {
|
|
76007
76032
|
console.log('Syncing style...');
|
|
76008
|
-
syncPromises.push(syncStyle());
|
|
76033
|
+
syncPromises.push(syncStyle(configPath));
|
|
76009
76034
|
}
|
|
76010
76035
|
if (components.includes('assets')) {
|
|
76011
76036
|
console.log('Syncing assets...');
|
|
76012
|
-
syncPromises.push(syncAssets());
|
|
76037
|
+
syncPromises.push(syncAssets(configPath));
|
|
76013
76038
|
}
|
|
76014
76039
|
if (components.includes('packages')) {
|
|
76015
76040
|
console.log('Syncing packages...');
|
|
@@ -76018,20 +76043,20 @@ const executeSyncOperations = async (components) => {
|
|
|
76018
76043
|
await Promise.all(syncPromises);
|
|
76019
76044
|
console.log('Sync operations completed successfully!');
|
|
76020
76045
|
};
|
|
76021
|
-
const executeInfoOperations = async (components) => {
|
|
76046
|
+
const executeInfoOperations = async (components, configPath) => {
|
|
76022
76047
|
console.log('\nFetching component information...');
|
|
76023
76048
|
const infoPromises = [];
|
|
76024
76049
|
if (components.includes('pages')) {
|
|
76025
76050
|
console.log('Getting pages info...');
|
|
76026
|
-
infoPromises.push(showPagesInfo());
|
|
76051
|
+
infoPromises.push(showPagesInfo(configPath));
|
|
76027
76052
|
}
|
|
76028
76053
|
if (components.includes('style')) {
|
|
76029
76054
|
console.log('Getting style info...');
|
|
76030
|
-
infoPromises.push(showStyleInfo());
|
|
76055
|
+
infoPromises.push(showStyleInfo(configPath));
|
|
76031
76056
|
}
|
|
76032
76057
|
if (components.includes('assets')) {
|
|
76033
76058
|
console.log('Getting assets info...');
|
|
76034
|
-
infoPromises.push(showAssetsInfo());
|
|
76059
|
+
infoPromises.push(showAssetsInfo(configPath));
|
|
76035
76060
|
}
|
|
76036
76061
|
if (components.includes('packages')) {
|
|
76037
76062
|
console.log('Getting packages info...');
|
|
@@ -76043,20 +76068,20 @@ const executeInfoOperations = async (components) => {
|
|
|
76043
76068
|
await Promise.all(infoPromises);
|
|
76044
76069
|
console.log('Info operations completed successfully!');
|
|
76045
76070
|
};
|
|
76046
|
-
const globalSync = async () => {
|
|
76071
|
+
const globalSync = async (configPath) => {
|
|
76047
76072
|
try {
|
|
76048
76073
|
const components = await promptForComponentSelection();
|
|
76049
|
-
await executeSyncOperations(components);
|
|
76074
|
+
await executeSyncOperations(components, configPath);
|
|
76050
76075
|
}
|
|
76051
76076
|
catch (error) {
|
|
76052
76077
|
console.error('Error during global sync:', error);
|
|
76053
76078
|
process.exit(1);
|
|
76054
76079
|
}
|
|
76055
76080
|
};
|
|
76056
|
-
const globalInfo = async () => {
|
|
76081
|
+
const globalInfo = async (configPath) => {
|
|
76057
76082
|
try {
|
|
76058
76083
|
const components = await promptForComponentSelection();
|
|
76059
|
-
await executeInfoOperations(components);
|
|
76084
|
+
await executeInfoOperations(components, configPath);
|
|
76060
76085
|
}
|
|
76061
76086
|
catch (error) {
|
|
76062
76087
|
console.error('Error during global info:', error);
|
|
@@ -76069,9 +76094,10 @@ program.name('mapples').description('Mapples CLI').version('0.0.0');
|
|
|
76069
76094
|
program
|
|
76070
76095
|
.command('init')
|
|
76071
76096
|
.description('Initialize Mapples project configuration')
|
|
76072
|
-
.
|
|
76097
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76098
|
+
.action(async (options) => {
|
|
76073
76099
|
try {
|
|
76074
|
-
await initProject();
|
|
76100
|
+
await initProject(options.config);
|
|
76075
76101
|
}
|
|
76076
76102
|
catch (error) {
|
|
76077
76103
|
console.error('Error initializing project:', error);
|
|
@@ -76083,13 +76109,14 @@ program
|
|
|
76083
76109
|
.description('Manage Mapples pages')
|
|
76084
76110
|
.option('--sync', 'Synchronize pages from the API')
|
|
76085
76111
|
.option('--info', 'Show information about pages')
|
|
76112
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76086
76113
|
.action(async (options) => {
|
|
76087
76114
|
try {
|
|
76088
76115
|
if (options.sync) {
|
|
76089
|
-
await syncPages();
|
|
76116
|
+
await syncPages(options.config);
|
|
76090
76117
|
}
|
|
76091
76118
|
else if (options.info) {
|
|
76092
|
-
await showPagesInfo();
|
|
76119
|
+
await showPagesInfo(options.config);
|
|
76093
76120
|
}
|
|
76094
76121
|
else {
|
|
76095
76122
|
console.log('Please specify an option: --sync, --info');
|
|
@@ -76105,6 +76132,7 @@ program
|
|
|
76105
76132
|
.description('Manage Mapples packages')
|
|
76106
76133
|
.option('--sync', 'Synchronize packages from package-list.json')
|
|
76107
76134
|
.option('--info', 'Show information about packages')
|
|
76135
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76108
76136
|
.action(async (options) => {
|
|
76109
76137
|
try {
|
|
76110
76138
|
if (options.sync) {
|
|
@@ -76127,13 +76155,14 @@ program
|
|
|
76127
76155
|
.description('Manage Mapples style')
|
|
76128
76156
|
.option('--sync', 'Synchronize style from the API')
|
|
76129
76157
|
.option('--info', 'Show information about style')
|
|
76158
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76130
76159
|
.action(async (options) => {
|
|
76131
76160
|
try {
|
|
76132
76161
|
if (options.sync) {
|
|
76133
|
-
await syncStyle();
|
|
76162
|
+
await syncStyle(options.config);
|
|
76134
76163
|
}
|
|
76135
76164
|
else if (options.info) {
|
|
76136
|
-
await showStyleInfo();
|
|
76165
|
+
await showStyleInfo(options.config);
|
|
76137
76166
|
}
|
|
76138
76167
|
else {
|
|
76139
76168
|
console.log('Please specify an option: --sync, --info');
|
|
@@ -76149,13 +76178,14 @@ program
|
|
|
76149
76178
|
.description('Manage Mapples assets')
|
|
76150
76179
|
.option('--sync', 'Synchronize assets from the API')
|
|
76151
76180
|
.option('--info', 'Show information about assets')
|
|
76181
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76152
76182
|
.action(async (options) => {
|
|
76153
76183
|
try {
|
|
76154
76184
|
if (options.sync) {
|
|
76155
|
-
await syncAssets();
|
|
76185
|
+
await syncAssets(options.config);
|
|
76156
76186
|
}
|
|
76157
76187
|
else if (options.info) {
|
|
76158
|
-
await showAssetsInfo();
|
|
76188
|
+
await showAssetsInfo(options.config);
|
|
76159
76189
|
}
|
|
76160
76190
|
else {
|
|
76161
76191
|
console.log('Please specify an option: --sync, --info');
|
|
@@ -76169,9 +76199,10 @@ program
|
|
|
76169
76199
|
program
|
|
76170
76200
|
.command('sync')
|
|
76171
76201
|
.description('Synchronize selected Mapples components')
|
|
76172
|
-
.
|
|
76202
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76203
|
+
.action(async (options) => {
|
|
76173
76204
|
try {
|
|
76174
|
-
await globalSync();
|
|
76205
|
+
await globalSync(options.config);
|
|
76175
76206
|
}
|
|
76176
76207
|
catch (error) {
|
|
76177
76208
|
console.error('Error during global sync:', error);
|
|
@@ -76181,9 +76212,10 @@ program
|
|
|
76181
76212
|
program
|
|
76182
76213
|
.command('info')
|
|
76183
76214
|
.description('Show information about selected Mapples components')
|
|
76184
|
-
.
|
|
76215
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76216
|
+
.action(async (options) => {
|
|
76185
76217
|
try {
|
|
76186
|
-
await globalInfo();
|
|
76218
|
+
await globalInfo(options.config);
|
|
76187
76219
|
}
|
|
76188
76220
|
catch (error) {
|
|
76189
76221
|
console.error('Error during global info:', error);
|