@mapples/cli 0.0.9 → 0.0.10
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 +3 -3
- package/dist/index.js +123 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ This command will:
|
|
|
46
46
|
- Generate React components using templates
|
|
47
47
|
- Create page directories with the following structure:
|
|
48
48
|
```
|
|
49
|
-
|
|
49
|
+
mapples/pages/{PageName}/
|
|
50
50
|
├── {PageName}Mapplet.tsx
|
|
51
51
|
├── {PageName}.json
|
|
52
52
|
├── _meta_{PageName}.json
|
|
@@ -82,7 +82,7 @@ The CLI uses a `.mapplesrc.json` file for configuration. Here are the available
|
|
|
82
82
|
"pagesDir": "pages",
|
|
83
83
|
"styleDir": "style",
|
|
84
84
|
"assetsDir": "assets",
|
|
85
|
-
"sourceDir": "
|
|
85
|
+
"sourceDir": "mapples"
|
|
86
86
|
}
|
|
87
87
|
```
|
|
88
88
|
|
|
@@ -95,7 +95,7 @@ The CLI uses a `.mapplesrc.json` file for configuration. Here are the available
|
|
|
95
95
|
- **pagesDir**: Directory name for pages (default: "pages")
|
|
96
96
|
- **styleDir**: Directory name for styles (default: "style")
|
|
97
97
|
- **assetsDir**: Directory name for assets (default: "assets")
|
|
98
|
-
- **sourceDir**: Source directory name (default: "
|
|
98
|
+
- **sourceDir**: Source directory name (default: "mapples")
|
|
99
99
|
|
|
100
100
|
## Generated Files
|
|
101
101
|
|
package/dist/index.js
CHANGED
|
@@ -23376,16 +23376,16 @@ function requireSubscription () {
|
|
|
23376
23376
|
return Subscription;
|
|
23377
23377
|
}
|
|
23378
23378
|
|
|
23379
|
-
var config
|
|
23379
|
+
var config = {};
|
|
23380
23380
|
|
|
23381
23381
|
var hasRequiredConfig;
|
|
23382
23382
|
|
|
23383
23383
|
function requireConfig () {
|
|
23384
|
-
if (hasRequiredConfig) return config
|
|
23384
|
+
if (hasRequiredConfig) return config;
|
|
23385
23385
|
hasRequiredConfig = 1;
|
|
23386
|
-
Object.defineProperty(config
|
|
23387
|
-
config
|
|
23388
|
-
config
|
|
23386
|
+
Object.defineProperty(config, "__esModule", { value: true });
|
|
23387
|
+
config.config = void 0;
|
|
23388
|
+
config.config = {
|
|
23389
23389
|
onUnhandledError: null,
|
|
23390
23390
|
onStoppedNotification: null,
|
|
23391
23391
|
Promise: undefined,
|
|
@@ -23393,7 +23393,7 @@ function requireConfig () {
|
|
|
23393
23393
|
useDeprecatedNextContext: false,
|
|
23394
23394
|
};
|
|
23395
23395
|
|
|
23396
|
-
return config
|
|
23396
|
+
return config;
|
|
23397
23397
|
}
|
|
23398
23398
|
|
|
23399
23399
|
var reportUnhandledError = {};
|
|
@@ -50244,7 +50244,7 @@ const DEFAULT_CONFIG = {
|
|
|
50244
50244
|
sandboxUrl: 'https://staging.mapples.org',
|
|
50245
50245
|
assetUrl: 'https://staging.assets.mapples.org',
|
|
50246
50246
|
useExpoRouter: false,
|
|
50247
|
-
sourceDir: '
|
|
50247
|
+
sourceDir: 'mapples',
|
|
50248
50248
|
dirs: {
|
|
50249
50249
|
pages: 'pages',
|
|
50250
50250
|
style: 'style',
|
|
@@ -52818,6 +52818,87 @@ const getPackageVersionFromJson = (packageName) => {
|
|
|
52818
52818
|
const getInstalledVersion = (packageName) => {
|
|
52819
52819
|
return getPackageVersionFromJson(packageName);
|
|
52820
52820
|
};
|
|
52821
|
+
const parseVersion = (version) => {
|
|
52822
|
+
const parts = version.split('.').map(Number);
|
|
52823
|
+
while (parts.length < 3) {
|
|
52824
|
+
parts.push(0);
|
|
52825
|
+
}
|
|
52826
|
+
return parts;
|
|
52827
|
+
};
|
|
52828
|
+
const compareVersions = (v1, v2) => {
|
|
52829
|
+
const parts1 = parseVersion(v1);
|
|
52830
|
+
const parts2 = parseVersion(v2);
|
|
52831
|
+
for (let i = 0; i < 3; i++) {
|
|
52832
|
+
if (parts1[i] < parts2[i])
|
|
52833
|
+
return -1;
|
|
52834
|
+
if (parts1[i] > parts2[i])
|
|
52835
|
+
return 1;
|
|
52836
|
+
}
|
|
52837
|
+
return 0;
|
|
52838
|
+
};
|
|
52839
|
+
const isVersionSatisfied = (installedVersion, latestVersion) => {
|
|
52840
|
+
try {
|
|
52841
|
+
// Remove whitespace
|
|
52842
|
+
const installed = installedVersion.trim();
|
|
52843
|
+
const latest = latestVersion.trim();
|
|
52844
|
+
// If exact match (starts with a digit, no prefix), do exact comparison
|
|
52845
|
+
if (/^\d/.test(installed)) {
|
|
52846
|
+
return compareVersions(installed, latest) === 0;
|
|
52847
|
+
}
|
|
52848
|
+
// Handle caret (^) prefix: ^1.0.3 means >=1.0.3 <2.0.0
|
|
52849
|
+
if (installed.startsWith('^')) {
|
|
52850
|
+
const baseVersion = installed.slice(1);
|
|
52851
|
+
const baseParts = parseVersion(baseVersion);
|
|
52852
|
+
// Check if latest >= base version
|
|
52853
|
+
if (compareVersions(latest, baseVersion) < 0) {
|
|
52854
|
+
return false;
|
|
52855
|
+
}
|
|
52856
|
+
// Check if latest < next major version
|
|
52857
|
+
const nextMajor = [baseParts[0] + 1, 0, 0];
|
|
52858
|
+
const nextMajorStr = nextMajor.join('.');
|
|
52859
|
+
return compareVersions(latest, nextMajorStr) < 0;
|
|
52860
|
+
}
|
|
52861
|
+
// Handle tilde (~) prefix: ~1.0.3 means >=1.0.3 <1.1.0
|
|
52862
|
+
if (installed.startsWith('~')) {
|
|
52863
|
+
const baseVersion = installed.slice(1);
|
|
52864
|
+
const baseParts = parseVersion(baseVersion);
|
|
52865
|
+
// Check if latest >= base version
|
|
52866
|
+
if (compareVersions(latest, baseVersion) < 0) {
|
|
52867
|
+
return false;
|
|
52868
|
+
}
|
|
52869
|
+
// Check if latest < next minor version
|
|
52870
|
+
const nextMinor = [baseParts[0], baseParts[1] + 1, 0];
|
|
52871
|
+
const nextMinorStr = nextMinor.join('.');
|
|
52872
|
+
return compareVersions(latest, nextMinorStr) < 0;
|
|
52873
|
+
}
|
|
52874
|
+
// Handle >= prefix
|
|
52875
|
+
if (installed.startsWith('>=')) {
|
|
52876
|
+
const minVersion = installed.slice(2);
|
|
52877
|
+
return compareVersions(latest, minVersion) >= 0;
|
|
52878
|
+
}
|
|
52879
|
+
// Handle <= prefix
|
|
52880
|
+
if (installed.startsWith('<=')) {
|
|
52881
|
+
const maxVersion = installed.slice(2);
|
|
52882
|
+
return compareVersions(latest, maxVersion) <= 0;
|
|
52883
|
+
}
|
|
52884
|
+
// Handle > prefix
|
|
52885
|
+
if (installed.startsWith('>')) {
|
|
52886
|
+
const minVersion = installed.slice(1);
|
|
52887
|
+
return compareVersions(latest, minVersion) > 0;
|
|
52888
|
+
}
|
|
52889
|
+
// Handle < prefix
|
|
52890
|
+
if (installed.startsWith('<')) {
|
|
52891
|
+
const maxVersion = installed.slice(1);
|
|
52892
|
+
return compareVersions(latest, maxVersion) < 0;
|
|
52893
|
+
}
|
|
52894
|
+
// If we can't parse it, fall back to string comparison
|
|
52895
|
+
return installed === latest;
|
|
52896
|
+
}
|
|
52897
|
+
catch {
|
|
52898
|
+
// If parsing fails, fall back to string comparison
|
|
52899
|
+
return installedVersion === latestVersion;
|
|
52900
|
+
}
|
|
52901
|
+
};
|
|
52821
52902
|
const installPackage = (packageName, version, packageManager) => {
|
|
52822
52903
|
try {
|
|
52823
52904
|
let command;
|
|
@@ -52938,7 +53019,7 @@ const syncPackages = async (autoApprove = false) => {
|
|
|
52938
53019
|
type: 'mapples',
|
|
52939
53020
|
});
|
|
52940
53021
|
}
|
|
52941
|
-
else if (installedVersion
|
|
53022
|
+
else if (!isVersionSatisfied(installedVersion, latestVersion)) {
|
|
52942
53023
|
packagesToUpdate.push({
|
|
52943
53024
|
name: packageName,
|
|
52944
53025
|
currentVersion: installedVersion,
|
|
@@ -53068,7 +53149,7 @@ const showPackageInfo = () => {
|
|
|
53068
53149
|
if (!installedVersion) {
|
|
53069
53150
|
console.log(chalk.red(` • ${packageName}: not installed (latest: ${latestVersion || 'unknown'})`));
|
|
53070
53151
|
}
|
|
53071
|
-
else if (installedVersion
|
|
53152
|
+
else if (!latestVersion || !isVersionSatisfied(installedVersion, latestVersion)) {
|
|
53072
53153
|
console.log(chalk.yellow(` • ${packageName}: ${installedVersion} (latest: ${latestVersion || 'unknown'})`));
|
|
53073
53154
|
}
|
|
53074
53155
|
else {
|
|
@@ -75739,19 +75820,41 @@ const assetsService = (axiosInstance) => {
|
|
|
75739
75820
|
};
|
|
75740
75821
|
};
|
|
75741
75822
|
|
|
75742
|
-
|
|
75743
|
-
const
|
|
75744
|
-
|
|
75745
|
-
|
|
75746
|
-
|
|
75823
|
+
let sandboxAxiosInstance = null;
|
|
75824
|
+
const getAxiosInstance = () => {
|
|
75825
|
+
const config = readConfig() || { ...DEFAULT_CONFIG, apiKey: '' };
|
|
75826
|
+
// Create or update the axios instance with current config
|
|
75827
|
+
if (!sandboxAxiosInstance) {
|
|
75828
|
+
sandboxAxiosInstance = axios.create({
|
|
75829
|
+
baseURL: config.sandboxUrl,
|
|
75830
|
+
headers: {
|
|
75831
|
+
'X-API-Key': config.apiKey,
|
|
75832
|
+
},
|
|
75833
|
+
});
|
|
75834
|
+
}
|
|
75835
|
+
else {
|
|
75836
|
+
// Update the existing instance with new config
|
|
75837
|
+
sandboxAxiosInstance.defaults.baseURL = config.sandboxUrl;
|
|
75838
|
+
sandboxAxiosInstance.defaults.headers['X-API-Key'] = config.apiKey;
|
|
75839
|
+
}
|
|
75840
|
+
return sandboxAxiosInstance;
|
|
75841
|
+
};
|
|
75842
|
+
const getServices = () => {
|
|
75843
|
+
const instance = getAxiosInstance();
|
|
75844
|
+
return {
|
|
75845
|
+
pages: pagesService(instance),
|
|
75846
|
+
project: projectService(instance),
|
|
75847
|
+
style: styleService(instance),
|
|
75848
|
+
assets: assetsService(instance),
|
|
75849
|
+
};
|
|
75850
|
+
};
|
|
75851
|
+
// Initialize services with lazy loading
|
|
75852
|
+
const services = new Proxy({}, {
|
|
75853
|
+
get(_, prop) {
|
|
75854
|
+
const servicesInstance = getServices();
|
|
75855
|
+
return servicesInstance[prop];
|
|
75747
75856
|
},
|
|
75748
75857
|
});
|
|
75749
|
-
const services = {
|
|
75750
|
-
pages: pagesService(sandboxAxiosInstance),
|
|
75751
|
-
project: projectService(sandboxAxiosInstance),
|
|
75752
|
-
style: styleService(sandboxAxiosInstance),
|
|
75753
|
-
assets: assetsService(sandboxAxiosInstance),
|
|
75754
|
-
};
|
|
75755
75858
|
|
|
75756
75859
|
const fetchPages = async () => {
|
|
75757
75860
|
try {
|