@mapples/cli 0.0.3 → 0.0.6
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/README.md +2 -2
- 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 +86 -46
- package/dist/index.js.map +1 -1
- package/dist/utils/config.d.ts +3 -2
- package/package.json +1 -1
- package/templates/PageTemplate/.donotedit +8 -1
- package/templates/PageTemplate/index.ts.tmpl +1 -1
- package/templates/PageTemplate/{{PageName}}Mapplet.tsx.tmpl +23 -0
- package/templates/PageTemplate/{{PageName}}Component.tsx.tmpl +0 -8
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ This command will:
|
|
|
47
47
|
- Create page directories with the following structure:
|
|
48
48
|
```
|
|
49
49
|
src/pages/{PageName}/
|
|
50
|
-
├── {PageName}
|
|
50
|
+
├── {PageName}Mapplet.tsx
|
|
51
51
|
├── {PageName}.json
|
|
52
52
|
├── _meta_{PageName}.json
|
|
53
53
|
├── index.ts
|
|
@@ -101,7 +101,7 @@ The CLI uses a `.mapplesrc.json` file for configuration. Here are the available
|
|
|
101
101
|
|
|
102
102
|
When synchronizing pages, the CLI generates the following files for each page:
|
|
103
103
|
|
|
104
|
-
### Component File (`{PageName}
|
|
104
|
+
### Component File (`{PageName}Mapplet.tsx`)
|
|
105
105
|
|
|
106
106
|
A React component that uses the `@mapples/render` package to render page content.
|
|
107
107
|
|
|
@@ -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';
|
|
@@ -75325,6 +75350,8 @@ const createPageFromTemplates = (pageName, pageData, config) => {
|
|
|
75325
75350
|
const templateDir = path.resolve(__dirname, '../templates/PageTemplate');
|
|
75326
75351
|
const destDir = path.join(process.cwd(), config.sourceDir, config.dirs.pages, pageName);
|
|
75327
75352
|
ensureDirectoryExists$2(destDir);
|
|
75353
|
+
// Files that should not be overwritten if they already exist
|
|
75354
|
+
const protectedExtensions = ['.tsx'];
|
|
75328
75355
|
const templateFiles = fs.readdirSync(templateDir);
|
|
75329
75356
|
templateFiles.forEach((file) => {
|
|
75330
75357
|
const templatePath = path.join(templateDir, file);
|
|
@@ -75338,6 +75365,12 @@ const createPageFromTemplates = (pageName, pageData, config) => {
|
|
|
75338
75365
|
}
|
|
75339
75366
|
destFileName = destFileName.replace(/{{PageName}}/g, pageName).replace(/\.tmpl$/, '');
|
|
75340
75367
|
const destPath = path.join(destDir, destFileName);
|
|
75368
|
+
// Check if this file has a protected extension and already exists
|
|
75369
|
+
const fileExtension = path.extname(destFileName);
|
|
75370
|
+
if (protectedExtensions.includes(fileExtension) && fs.existsSync(destPath)) {
|
|
75371
|
+
console.log(`Skipping protected file: ${destFileName}`);
|
|
75372
|
+
return;
|
|
75373
|
+
}
|
|
75341
75374
|
if (file === `_meta_{{PageName}}.json.tmpl`) {
|
|
75342
75375
|
const metaData = lodashExports.cloneDeep(pageData);
|
|
75343
75376
|
lodashExports.unset(metaData, 'data');
|
|
@@ -75346,15 +75379,15 @@ const createPageFromTemplates = (pageName, pageData, config) => {
|
|
|
75346
75379
|
else if (file === `{{PageName}}.json.tmpl`) {
|
|
75347
75380
|
writeJsonToFile(destPath, pageData.data || {});
|
|
75348
75381
|
}
|
|
75349
|
-
else if (file === `{{PageName}}
|
|
75382
|
+
else if (file === `{{PageName}}Mapplet.tsx.tmpl` || file === `index.ts.tmpl`) {
|
|
75350
75383
|
processTemplateFile(templatePath, destPath, { PageName: pageName });
|
|
75351
75384
|
}
|
|
75352
75385
|
});
|
|
75353
75386
|
console.log(`Created page: ${pageName}`);
|
|
75354
75387
|
};
|
|
75355
|
-
const syncPages = async () => {
|
|
75388
|
+
const syncPages = async (configPath) => {
|
|
75356
75389
|
try {
|
|
75357
|
-
const config = readConfig();
|
|
75390
|
+
const config = readConfig(configPath);
|
|
75358
75391
|
if (!config) {
|
|
75359
75392
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75360
75393
|
process.exit(1);
|
|
@@ -75372,10 +75405,10 @@ const syncPages = async () => {
|
|
|
75372
75405
|
process.exit(1);
|
|
75373
75406
|
}
|
|
75374
75407
|
};
|
|
75375
|
-
const showPagesInfo = async () => {
|
|
75408
|
+
const showPagesInfo = async (configPath) => {
|
|
75376
75409
|
try {
|
|
75377
75410
|
console.log('Fetching pages...');
|
|
75378
|
-
const config = readConfig();
|
|
75411
|
+
const config = readConfig(configPath);
|
|
75379
75412
|
if (!config) {
|
|
75380
75413
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75381
75414
|
process.exit(1);
|
|
@@ -75461,9 +75494,9 @@ const createDonotEditFile = (styleDir) => {
|
|
|
75461
75494
|
fs.writeFileSync(donotEditPath, '');
|
|
75462
75495
|
}
|
|
75463
75496
|
};
|
|
75464
|
-
const syncStyle = async () => {
|
|
75497
|
+
const syncStyle = async (configPath) => {
|
|
75465
75498
|
try {
|
|
75466
|
-
const config = readConfig();
|
|
75499
|
+
const config = readConfig(configPath);
|
|
75467
75500
|
if (!config) {
|
|
75468
75501
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75469
75502
|
process.exit(1);
|
|
@@ -75499,10 +75532,10 @@ const syncStyle = async () => {
|
|
|
75499
75532
|
process.exit(1);
|
|
75500
75533
|
}
|
|
75501
75534
|
};
|
|
75502
|
-
const showStyleInfo = async () => {
|
|
75535
|
+
const showStyleInfo = async (configPath) => {
|
|
75503
75536
|
try {
|
|
75504
75537
|
console.log('Fetching style...');
|
|
75505
|
-
const config = readConfig();
|
|
75538
|
+
const config = readConfig(configPath);
|
|
75506
75539
|
if (!config) {
|
|
75507
75540
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75508
75541
|
process.exit(1);
|
|
@@ -75650,9 +75683,9 @@ const getExistingMetaFiles = (config) => {
|
|
|
75650
75683
|
}
|
|
75651
75684
|
return existingFiles;
|
|
75652
75685
|
};
|
|
75653
|
-
const syncAssets = async () => {
|
|
75686
|
+
const syncAssets = async (configPath) => {
|
|
75654
75687
|
try {
|
|
75655
|
-
const config = readConfig();
|
|
75688
|
+
const config = readConfig(configPath);
|
|
75656
75689
|
if (!config) {
|
|
75657
75690
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75658
75691
|
process.exit(1);
|
|
@@ -75735,10 +75768,10 @@ const syncAssets = async () => {
|
|
|
75735
75768
|
process.exit(1);
|
|
75736
75769
|
}
|
|
75737
75770
|
};
|
|
75738
|
-
const showAssetsInfo = async () => {
|
|
75771
|
+
const showAssetsInfo = async (configPath) => {
|
|
75739
75772
|
try {
|
|
75740
75773
|
console.log('Fetching assets...');
|
|
75741
|
-
const config = readConfig();
|
|
75774
|
+
const config = readConfig(configPath);
|
|
75742
75775
|
if (!config) {
|
|
75743
75776
|
console.error('Configuration not found. Run "mapples init" first.');
|
|
75744
75777
|
process.exit(1);
|
|
@@ -75925,9 +75958,9 @@ const executeSyncOperations$1 = async (syncOptions) => {
|
|
|
75925
75958
|
await Promise.all(syncPromises);
|
|
75926
75959
|
console.log('Sync operations completed successfully!');
|
|
75927
75960
|
};
|
|
75928
|
-
const initProject = async () => {
|
|
75961
|
+
const initProject = async (configPath) => {
|
|
75929
75962
|
try {
|
|
75930
|
-
const existingConfig = readConfig();
|
|
75963
|
+
const existingConfig = readConfig(configPath);
|
|
75931
75964
|
if (existingConfig) {
|
|
75932
75965
|
console.log('Updating existing Mapples project configuration...');
|
|
75933
75966
|
}
|
|
@@ -75935,7 +75968,7 @@ const initProject = async () => {
|
|
|
75935
75968
|
console.log('Initializing Mapples project...');
|
|
75936
75969
|
}
|
|
75937
75970
|
const config = await promptForConfig();
|
|
75938
|
-
writeConfig(config);
|
|
75971
|
+
writeConfig(config, configPath);
|
|
75939
75972
|
updateGitignore();
|
|
75940
75973
|
console.log('Project initialization completed successfully');
|
|
75941
75974
|
const { installPackages } = await inquirer.prompt([
|
|
@@ -75996,20 +76029,20 @@ const promptForComponentSelection = async () => {
|
|
|
75996
76029
|
}
|
|
75997
76030
|
return selectedComponents;
|
|
75998
76031
|
};
|
|
75999
|
-
const executeSyncOperations = async (components) => {
|
|
76032
|
+
const executeSyncOperations = async (components, configPath) => {
|
|
76000
76033
|
console.log('\nStarting sync operations...');
|
|
76001
76034
|
const syncPromises = [];
|
|
76002
76035
|
if (components.includes('pages')) {
|
|
76003
76036
|
console.log('Syncing pages...');
|
|
76004
|
-
syncPromises.push(syncPages());
|
|
76037
|
+
syncPromises.push(syncPages(configPath));
|
|
76005
76038
|
}
|
|
76006
76039
|
if (components.includes('style')) {
|
|
76007
76040
|
console.log('Syncing style...');
|
|
76008
|
-
syncPromises.push(syncStyle());
|
|
76041
|
+
syncPromises.push(syncStyle(configPath));
|
|
76009
76042
|
}
|
|
76010
76043
|
if (components.includes('assets')) {
|
|
76011
76044
|
console.log('Syncing assets...');
|
|
76012
|
-
syncPromises.push(syncAssets());
|
|
76045
|
+
syncPromises.push(syncAssets(configPath));
|
|
76013
76046
|
}
|
|
76014
76047
|
if (components.includes('packages')) {
|
|
76015
76048
|
console.log('Syncing packages...');
|
|
@@ -76018,20 +76051,20 @@ const executeSyncOperations = async (components) => {
|
|
|
76018
76051
|
await Promise.all(syncPromises);
|
|
76019
76052
|
console.log('Sync operations completed successfully!');
|
|
76020
76053
|
};
|
|
76021
|
-
const executeInfoOperations = async (components) => {
|
|
76054
|
+
const executeInfoOperations = async (components, configPath) => {
|
|
76022
76055
|
console.log('\nFetching component information...');
|
|
76023
76056
|
const infoPromises = [];
|
|
76024
76057
|
if (components.includes('pages')) {
|
|
76025
76058
|
console.log('Getting pages info...');
|
|
76026
|
-
infoPromises.push(showPagesInfo());
|
|
76059
|
+
infoPromises.push(showPagesInfo(configPath));
|
|
76027
76060
|
}
|
|
76028
76061
|
if (components.includes('style')) {
|
|
76029
76062
|
console.log('Getting style info...');
|
|
76030
|
-
infoPromises.push(showStyleInfo());
|
|
76063
|
+
infoPromises.push(showStyleInfo(configPath));
|
|
76031
76064
|
}
|
|
76032
76065
|
if (components.includes('assets')) {
|
|
76033
76066
|
console.log('Getting assets info...');
|
|
76034
|
-
infoPromises.push(showAssetsInfo());
|
|
76067
|
+
infoPromises.push(showAssetsInfo(configPath));
|
|
76035
76068
|
}
|
|
76036
76069
|
if (components.includes('packages')) {
|
|
76037
76070
|
console.log('Getting packages info...');
|
|
@@ -76043,20 +76076,20 @@ const executeInfoOperations = async (components) => {
|
|
|
76043
76076
|
await Promise.all(infoPromises);
|
|
76044
76077
|
console.log('Info operations completed successfully!');
|
|
76045
76078
|
};
|
|
76046
|
-
const globalSync = async () => {
|
|
76079
|
+
const globalSync = async (configPath) => {
|
|
76047
76080
|
try {
|
|
76048
76081
|
const components = await promptForComponentSelection();
|
|
76049
|
-
await executeSyncOperations(components);
|
|
76082
|
+
await executeSyncOperations(components, configPath);
|
|
76050
76083
|
}
|
|
76051
76084
|
catch (error) {
|
|
76052
76085
|
console.error('Error during global sync:', error);
|
|
76053
76086
|
process.exit(1);
|
|
76054
76087
|
}
|
|
76055
76088
|
};
|
|
76056
|
-
const globalInfo = async () => {
|
|
76089
|
+
const globalInfo = async (configPath) => {
|
|
76057
76090
|
try {
|
|
76058
76091
|
const components = await promptForComponentSelection();
|
|
76059
|
-
await executeInfoOperations(components);
|
|
76092
|
+
await executeInfoOperations(components, configPath);
|
|
76060
76093
|
}
|
|
76061
76094
|
catch (error) {
|
|
76062
76095
|
console.error('Error during global info:', error);
|
|
@@ -76069,9 +76102,10 @@ program.name('mapples').description('Mapples CLI').version('0.0.0');
|
|
|
76069
76102
|
program
|
|
76070
76103
|
.command('init')
|
|
76071
76104
|
.description('Initialize Mapples project configuration')
|
|
76072
|
-
.
|
|
76105
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76106
|
+
.action(async (options) => {
|
|
76073
76107
|
try {
|
|
76074
|
-
await initProject();
|
|
76108
|
+
await initProject(options.config);
|
|
76075
76109
|
}
|
|
76076
76110
|
catch (error) {
|
|
76077
76111
|
console.error('Error initializing project:', error);
|
|
@@ -76083,13 +76117,14 @@ program
|
|
|
76083
76117
|
.description('Manage Mapples pages')
|
|
76084
76118
|
.option('--sync', 'Synchronize pages from the API')
|
|
76085
76119
|
.option('--info', 'Show information about pages')
|
|
76120
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76086
76121
|
.action(async (options) => {
|
|
76087
76122
|
try {
|
|
76088
76123
|
if (options.sync) {
|
|
76089
|
-
await syncPages();
|
|
76124
|
+
await syncPages(options.config);
|
|
76090
76125
|
}
|
|
76091
76126
|
else if (options.info) {
|
|
76092
|
-
await showPagesInfo();
|
|
76127
|
+
await showPagesInfo(options.config);
|
|
76093
76128
|
}
|
|
76094
76129
|
else {
|
|
76095
76130
|
console.log('Please specify an option: --sync, --info');
|
|
@@ -76105,6 +76140,7 @@ program
|
|
|
76105
76140
|
.description('Manage Mapples packages')
|
|
76106
76141
|
.option('--sync', 'Synchronize packages from package-list.json')
|
|
76107
76142
|
.option('--info', 'Show information about packages')
|
|
76143
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76108
76144
|
.action(async (options) => {
|
|
76109
76145
|
try {
|
|
76110
76146
|
if (options.sync) {
|
|
@@ -76127,13 +76163,14 @@ program
|
|
|
76127
76163
|
.description('Manage Mapples style')
|
|
76128
76164
|
.option('--sync', 'Synchronize style from the API')
|
|
76129
76165
|
.option('--info', 'Show information about style')
|
|
76166
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76130
76167
|
.action(async (options) => {
|
|
76131
76168
|
try {
|
|
76132
76169
|
if (options.sync) {
|
|
76133
|
-
await syncStyle();
|
|
76170
|
+
await syncStyle(options.config);
|
|
76134
76171
|
}
|
|
76135
76172
|
else if (options.info) {
|
|
76136
|
-
await showStyleInfo();
|
|
76173
|
+
await showStyleInfo(options.config);
|
|
76137
76174
|
}
|
|
76138
76175
|
else {
|
|
76139
76176
|
console.log('Please specify an option: --sync, --info');
|
|
@@ -76149,13 +76186,14 @@ program
|
|
|
76149
76186
|
.description('Manage Mapples assets')
|
|
76150
76187
|
.option('--sync', 'Synchronize assets from the API')
|
|
76151
76188
|
.option('--info', 'Show information about assets')
|
|
76189
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76152
76190
|
.action(async (options) => {
|
|
76153
76191
|
try {
|
|
76154
76192
|
if (options.sync) {
|
|
76155
|
-
await syncAssets();
|
|
76193
|
+
await syncAssets(options.config);
|
|
76156
76194
|
}
|
|
76157
76195
|
else if (options.info) {
|
|
76158
|
-
await showAssetsInfo();
|
|
76196
|
+
await showAssetsInfo(options.config);
|
|
76159
76197
|
}
|
|
76160
76198
|
else {
|
|
76161
76199
|
console.log('Please specify an option: --sync, --info');
|
|
@@ -76169,9 +76207,10 @@ program
|
|
|
76169
76207
|
program
|
|
76170
76208
|
.command('sync')
|
|
76171
76209
|
.description('Synchronize selected Mapples components')
|
|
76172
|
-
.
|
|
76210
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76211
|
+
.action(async (options) => {
|
|
76173
76212
|
try {
|
|
76174
|
-
await globalSync();
|
|
76213
|
+
await globalSync(options.config);
|
|
76175
76214
|
}
|
|
76176
76215
|
catch (error) {
|
|
76177
76216
|
console.error('Error during global sync:', error);
|
|
@@ -76181,9 +76220,10 @@ program
|
|
|
76181
76220
|
program
|
|
76182
76221
|
.command('info')
|
|
76183
76222
|
.description('Show information about selected Mapples components')
|
|
76184
|
-
.
|
|
76223
|
+
.option('--config <path>', 'Path to the configuration file')
|
|
76224
|
+
.action(async (options) => {
|
|
76185
76225
|
try {
|
|
76186
|
-
await globalInfo();
|
|
76226
|
+
await globalInfo(options.config);
|
|
76187
76227
|
}
|
|
76188
76228
|
catch (error) {
|
|
76189
76229
|
console.error('Error during global info:', error);
|