standard-version-expo icon indicating copy to clipboard operation
standard-version-expo copied to clipboard

"Manifest must include a JSON object."

Open gregfenton opened this issue 5 years ago • 7 comments

Topic and scope of discussion

Unable to get version bumping for app.config.js files - getting the subject's message to the console.

Motivation

To understand if a flexible, dynamic configuration is currently possible.

Additional context

In my .versionrc.js I have the following:

/*
 * From https://gist.github.com/gregfenton/b81ec014e8488dc5576f8444cbf7bcd4
 */
let fs = require('fs');

let bumps = [
  {filename: 'package.json'},
];

let CONFIGS_DIR = './customer-configs';

try {
  let entries = fs.readdirSync(CONFIGS_DIR, {withFileTypes: true});
  for (let i = 0; i < entries.length; i++) {
    let entry = entries[i];
    let confFile = `${CONFIGS_DIR}/${entry.name}/app.config.js`;
    if (entry?.isDirectory()) {ame: 
      if (fs.existsSync(confFile)) {
        // updates `expo.version`
        bumps.push({
          filename: confFile,
          updater: require.resolve('standard-version-expo'),
        });
        // updates `expo.android.versionCode`
        bumps.push({
          filename: confFile,
          updater: require.resolve('standard-version-expo/android'),
        });
        // updates `expo.ios.buildNumber`
        bumps.push({
          filename: confFile,
          updater: require.resolve('standard-version-expo/ios'),
        });
      }
    }
  }
} catch (ex) {
  console.log(`EXCEPTION with readdir: ${ex.message}`);
  throw ex;
}

module.exports = {
  bumpFiles: [...bumps],
};

When I run npx standard-version --dry-run I get the following output:

$ npx standard-version --dry-run
✔ bumping version in package.json from 0.2.17 to 0.2.18
Manifest must include a JSON object.
Manifest must include a JSON object.
Manifest must include a JSON object.
Manifest must include a JSON object.
Manifest must include a JSON object.
Manifest must include a JSON object.
✔ outputting changes to CHANGELOG.md

---
### [0.2.18](https://github.com/gregfenton/rn_tick8s/compare/v0.2.17...v0.2.18) (2020-10-17)
---

✔ committing package.json and CHANGELOG.md
✔ tagging release v0.2.18
ℹ Run `git push --follow-tags origin main` to publish

and my app.config.js files do not update. I have 2 app.config.js files (I have 2 customer-configs), and I'm quite certain that the 6 instances of "Manifest must include a JSON object." are coming from (2 customer-configs * 3 updaters).

Looking at the code in standard-version-expo/build/expo.js, it seems that the code to parseJsonString() is failing with the exception message ending with:

└─ Cause: SyntaxError: JSON5: invalid character 'i' at 1:1
> 1 | import fs from 'fs';
    | ^
  2 | 
  3 | const APP_NAME = 'tick8s';
  4 | const FB_PROJECT_NAME = 't8s-CUSTOMER-DETAILS-HERE';

So it is blowing up simply trying to read in the app.config.js.

Any thoughts on what I could try next? It clearly finds the config files, but fails to parse them

gregfenton avatar Oct 17 '20 16:10 gregfenton

@gregfenton it appears it lacks support for app.config.js: https://github.com/expo-community/standard-version-expo/issues/12 . It's a great library but I had to shelve use of it due to lack of support for app.config.js.

ourmaninamsterdam avatar Jan 21 '21 12:01 ourmaninamsterdam

A possible workaround is to use app.json and app.config.js. Example:

app.json:

{
 "expo": {
    "version": "0.2.5"
 }
}

app.config.js:

import appJson from "./app.json";

export default {
 ...
 version: appJson.expo.version,
 ...
}

There are actually other tools that don't play nice with app.config.js (e.g., detox)

oriharel avatar Mar 27 '21 10:03 oriharel

@oriharel - interesting, though then I wonder the value of using this extension over pure standard-version? I have essentially followed your approach, though I named my file version.json and I'm just using standard-version's configuration file .versionrc.js with:

/*
 * From https://gist.github.com/gregfenton/b81ec014e8488dc5576f8444cbf7bcd4
 */
const fs = require('fs');
const path = require('path');

const bumps = [
  {filename: 'package.json'},
]; // update the global project

const PROJECTS_DIR = './subprojects';
const VERSION_JSON_FILENAME = 'version.json';

try {
  let entries = fs.readdirSync(PROJECTS_DIR, {withFileTypes: true});
  for (let i = 0; i < entries.length; i++) {
    let entry = entries[i];
    if (entry?.isDirectory()) {
      let confFile = path.join(PROJECTS_DIR, entry.name, VERSION_JSON_FILENAME);
      if (fs.existsSync(confFile)) {
        bumps.push({
          filename: confFile,
          type: 'json',
        });
      }
    }
  }
} catch (ex) {
  console.log(`EXCEPTION with readdir(): ${ex.message}`);
  throw ex;
}

module.exports = {
  bumpFiles: [...bumps],
};

gregfenton avatar Mar 27 '21 15:03 gregfenton

I need this feature too...

Stevemoretz avatar Mar 31 '22 19:03 Stevemoretz

Having this feature would be helpful

sainijagjit avatar Jul 15 '22 00:07 sainijagjit

Note: standard-version is no longer being actively maintained 😕

gregfenton avatar Jul 15 '22 01:07 gregfenton

Note: standard-version is no longer being actively maintained 😕

Yeah that's a bummer but I think it's famous enough to get a serious fork.

Stevemoretz avatar Jul 15 '22 06:07 Stevemoretz