Skip to content

Change studio.json to meta.json - #623

Merged
sejas merged 4 commits into
trunkfrom
update/json-file-format
Oct 25, 2024
Merged

Change studio.json to meta.json#623
sejas merged 4 commits into
trunkfrom
update/json-file-format

Conversation

@wojtekn

@wojtekn wojtekn commented Oct 24, 2024

Copy link
Copy Markdown
Contributor

Resolves https://github.com/Automattic/dotcom-forge/issues/9351

Proposed Changes

I propose to change the default meta file name to meta.json and format to the following one:

{
  "siteUrl": "http://localhost:8889",
  "phpVersion": "8.1",
  "wordpressVersion": "6.6.2",
  "plugins": [
    {
      "name": "akismet",
      "status": "active",
      "version": "5.3.3"
    },
    {
      "name": "google-authenticator",
      "status": "active",
      "version": "0.54"
    },
    {
      "name": "jetpack",
      "status": "active",
      "version": "13.9.1"
    },
    {
      "name": "wp-postviews",
      "status": "inactive",
      "version": "1.77"
    }
  ],
  "themes": [
    {
      "name": "arrakkis",
      "status": "active",
      "version": "1.2.8"
    },
    {
      "name": "ubergrid",
      "status": "inactive",
      "version": "1.2.8"
    }
  ]
}

The data there will allow other systems like VaultPress to import the site easily.

Testing Instructions

Export

  1. Add a new site
  2. Install some themes on a site
  3. Install some plugins on a site
  4. Change PHP version to non-default one
  5. Export the entire site
  6. Open the export package and ensure that meta.json file exists and has the correct content

Import

  1. Add a new site
  2. Import the previously exported site to the new site
  3. Confirm non-default PHP version was set based on the version from meta.json file
  4. Optionally, test importing older backups that include studio.json file

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@wojtekn wojtekn self-assigned this Oct 24, 2024
@wojtekn
wojtekn marked this pull request as ready for review October 25, 2024 08:25
@wojtekn
wojtekn requested a review from a team October 25, 2024 08:25

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it exporting and I confirm the zip contains a meta.json file and not studio.json. Importing also worked as expected, it used the meta data to use the changed php version. It seems we don't support custom WordPress versions or at least in my example didn't use the version 6.5.5 I set in meta.json.

Export:

Screenshot 2024-10-25 at 10 54 51

Import test:

Screenshot 2024-10-25 at 10 56 55
} else if ( file.startsWith( 'wp-content/themes/' ) ) {
extractedBackup.wpContent.themes.push( fullPath );
} else if ( file === 'studio.json' ) {
} else if ( file === 'studio.json' || file === 'meta.json' ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart move by not removing the old studio.json 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@wojtekn

wojtekn commented Oct 25, 2024

Copy link
Copy Markdown
Contributor Author

It seems we don't support custom WordPress versions or at least in my example didn't use the version 6.5.5 I set in meta.json.

Correct, it's not supported yet.

@sejas
sejas merged commit 62fb4f4 into trunk Oct 25, 2024
@sejas
sejas deleted the update/json-file-format branch October 25, 2024 14:15
@sentry

sentry Bot commented Oct 29, 2024

Copy link
Copy Markdown

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ SyntaxError: Unexpected end of JSON input SqlExporter(main/studio/./src/lib/import-export... View Issue

Did you find this useful? React with a 👍 or 👎

@macbre

macbre commented Oct 29, 2024

Copy link
Copy Markdown
Member

Thanks!

Comment on lines +33 to +45
export interface StudioJson {
phpVersion: string;
wordpressVersion?: string;
siteUrl: string;
plugins: StudioJsonPluginOrTheme[];
themes: StudioJsonPluginOrTheme[];
}

export interface StudioJsonPluginOrTheme {
name: string;
status: 'active' | 'inactive';
version: string;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Thanks for pointing it out!

@wojtekn

wojtekn commented Oct 30, 2024

Copy link
Copy Markdown
Contributor Author

This pull request was deployed and Sentry observed the following issues:

  • ‼️ SyntaxError: Unexpected end of JSON input SqlExporter(main/studio/./src/lib/import-export... View Issue

I've added https://github.com/Automattic/dotcom-forge/issues/9582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants