@gadmin2n/cli 0.0.110 → 0.0.111

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.
@@ -49,11 +49,19 @@ function formatMaterializeError(schematicsVersion, err) {
49
49
  /* ------------------------------------------------------------------ *
50
50
  * Template config / path resolution
51
51
  * ------------------------------------------------------------------ */
52
- function resolveTemplatePath(templateName) {
53
- let schematicsRoot;
52
+ /**
53
+ * Locate the @gadmin2n/schematics install root, searching:
54
+ * 1. the instance project dir
55
+ * 2. the instance project's server/ subdir (where deps usually live)
56
+ * 3. the CLI's own node_modules (covers globally installed CLI where
57
+ * schematics ships alongside @gadmin2n/cli but is NOT installed in
58
+ * the user's project)
59
+ * Throws a helpful error if none of these resolve.
60
+ */
61
+ function findSchematicsRoot(instanceDir = process.cwd()) {
54
62
  const searchPaths = [
55
- process.cwd(),
56
- path.join(process.cwd(), 'server'),
63
+ instanceDir,
64
+ path.join(instanceDir, 'server'),
57
65
  path.resolve(__dirname, '..'),
58
66
  ];
59
67
  for (const searchPath of searchPaths) {
@@ -61,17 +69,18 @@ function resolveTemplatePath(templateName) {
61
69
  const pkgPath = require.resolve('@gadmin2n/schematics/package.json', {
62
70
  paths: [searchPath],
63
71
  });
64
- schematicsRoot = path.dirname(pkgPath);
65
- break;
72
+ return path.dirname(pkgPath);
66
73
  }
67
74
  catch (_a) {
68
75
  // continue
69
76
  }
70
77
  }
71
- if (!schematicsRoot) {
72
- throw new Error('Cannot resolve @gadmin2n/schematics package. ' +
73
- 'Make sure it is installed.');
74
- }
78
+ throw new Error('Cannot resolve @gadmin2n/schematics package. ' +
79
+ 'Make sure it is installed globally (alongside @gadmin2n/cli) ' +
80
+ 'or as a dependency of the project.');
81
+ }
82
+ function resolveTemplatePath(templateName) {
83
+ const schematicsRoot = findSchematicsRoot();
75
84
  const nameVariants = [templateName];
76
85
  if (templateName.startsWith('gadmin2n-')) {
77
86
  nameVariants.push(templateName.replace('gadmin2n-', 'gadmin2-'));
@@ -946,7 +955,8 @@ class UpdateAction extends abstract_action_1.AbstractAction {
946
955
  snapshotPackageJson(path.join(instanceDir, 'web'), 'web'),
947
956
  snapshotPackageJson(path.join(instanceDir, 'server'), 'server'),
948
957
  ];
949
- const schematicsPkg = require(require.resolve('@gadmin2n/schematics/package.json', { paths: [instanceDir, path.join(instanceDir, 'server')] }));
958
+ const schematicsRoot = findSchematicsRoot(instanceDir);
959
+ const schematicsPkg = require(path.join(schematicsRoot, 'package.json'));
950
960
  const schematicsVersion = schematicsPkg.version || '0.0.0';
951
961
  // First-time bootstrap: meta absent → write meta + README, exit.
952
962
  if (!fs.existsSync((0, base_store_1.metaPath)(instanceDir))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gadmin2n/cli",
3
- "version": "0.0.110",
3
+ "version": "0.0.111",
4
4
  "description": "Gadmin - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"