diff --git a/desktop/pkg/jestconfig.json b/desktop/pkg/jest.config.json similarity index 90% rename from desktop/pkg/jestconfig.json rename to desktop/pkg/jest.config.json index ea34bfc7e..6cd00eb00 100644 --- a/desktop/pkg/jestconfig.json +++ b/desktop/pkg/jest.config.json @@ -2,6 +2,7 @@ "transform": { "^.+\\.tsx?$": "ts-jest" }, + "testEnvironment": "node", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "testPathIgnorePatterns": [ "\/node_modules\/", diff --git a/desktop/pkg/src/__tests__/runInit.node.ts b/desktop/pkg/src/__tests__/runInit.node.ts index b42da7b2b..bda57996c 100644 --- a/desktop/pkg/src/__tests__/runInit.node.ts +++ b/desktop/pkg/src/__tests__/runInit.node.ts @@ -80,8 +80,7 @@ test('It generates the correct files for client plugin', async () => { \\"test\\": \\"jest --no-watchman\\" }, \\"peerDependencies\\": { - \\"flipper\\": \\"latest\\", - \\"flipper-plugin\\": \\"latest\\", + \\"flipper-plugin\\": \\"^0.0.0\\", \\"antd\\": \\"latest\\" }, \\"devDependencies\\": { @@ -92,7 +91,6 @@ test('It generates the correct files for client plugin', async () => { \\"@types/react\\": \\"latest\\", \\"@types/react-dom\\": \\"latest\\", \\"antd\\": \\"latest\\", - \\"flipper\\": \\"latest\\", \\"flipper-plugin\\": \\"latest\\", \\"flipper-pkg\\": \\"latest\\", \\"jest\\": \\"latest\\", @@ -258,8 +256,7 @@ test('It generates the correct files for device plugin', async () => { \\"test\\": \\"jest --no-watchman\\" }, \\"peerDependencies\\": { - \\"flipper\\": \\"latest\\", - \\"flipper-plugin\\": \\"latest\\", + \\"flipper-plugin\\": \\"^0.0.0\\", \\"antd\\": \\"latest\\" }, \\"devDependencies\\": { @@ -270,7 +267,6 @@ test('It generates the correct files for device plugin', async () => { \\"@types/react\\": \\"latest\\", \\"@types/react-dom\\": \\"latest\\", \\"antd\\": \\"latest\\", - \\"flipper\\": \\"latest\\", \\"flipper-plugin\\": \\"latest\\", \\"flipper-pkg\\": \\"latest\\", \\"jest\\": \\"latest\\", diff --git a/desktop/pkg/src/commands/init.ts b/desktop/pkg/src/commands/init.ts index 83ece650e..11abdbc18 100644 --- a/desktop/pkg/src/commands/init.ts +++ b/desktop/pkg/src/commands/init.ts @@ -147,6 +147,12 @@ export async function initTemplate( supportedDevices: string[] | undefined, outputDirectory: string, ) { + const flipper_version = JSON.parse( + await fs.readFile( + path.resolve(__dirname, '..', '..', 'package.json'), + 'utf-8', + ), + ).version; const packageName = getPackageNameFromId(id); const templateDir = pluginType === 'device' ? devicePluginTemplateDir : pluginTemplateDir; @@ -169,6 +175,7 @@ export async function initTemplate( .toString() .replace('{{id}}', id) .replace('{{title}}', title) + .replace('{{flipper_version}}', flipper_version) .replace( '{{supported_devices}}', JSON.stringify( diff --git a/desktop/pkg/templates/device-plugin/package.json.template b/desktop/pkg/templates/device-plugin/package.json.template index 6262b9380..313b1798a 100644 --- a/desktop/pkg/templates/device-plugin/package.json.template +++ b/desktop/pkg/templates/device-plugin/package.json.template @@ -21,8 +21,7 @@ "test": "jest --no-watchman" }, "peerDependencies": { - "flipper": "latest", - "flipper-plugin": "latest", + "flipper-plugin": "^{{flipper_version}}", "antd": "latest" }, "devDependencies": { @@ -33,7 +32,6 @@ "@types/react": "latest", "@types/react-dom": "latest", "antd": "latest", - "flipper": "latest", "flipper-plugin": "latest", "flipper-pkg": "latest", "jest": "latest", diff --git a/desktop/pkg/templates/plugin/package.json.template b/desktop/pkg/templates/plugin/package.json.template index 71234fcf9..56c59f906 100644 --- a/desktop/pkg/templates/plugin/package.json.template +++ b/desktop/pkg/templates/plugin/package.json.template @@ -20,8 +20,7 @@ "test": "jest --no-watchman" }, "peerDependencies": { - "flipper": "latest", - "flipper-plugin": "latest", + "flipper-plugin": "^{{flipper_version}}", "antd": "latest" }, "devDependencies": { @@ -32,7 +31,6 @@ "@types/react": "latest", "@types/react-dom": "latest", "antd": "latest", - "flipper": "latest", "flipper-plugin": "latest", "flipper-pkg": "latest", "jest": "latest", diff --git a/docs/tutorial/js-setup.mdx b/docs/tutorial/js-setup.mdx index 78ed3df92..2f349bab1 100644 --- a/docs/tutorial/js-setup.mdx +++ b/docs/tutorial/js-setup.mdx @@ -18,7 +18,10 @@ on the desktop side. ## Scaffolding a new Desktop plugin -A new Flipper Desktop plugin can be scaffolded by running `npx flipper-pkg init` in the directory where you want to store the plugin sources (Don't run this command inside the Flipper repository itself!). For example: +A new Flipper Desktop plugin can be scaffolded by running `npx flipper-pkg init` in the directory where you want to store the plugin sources (Don't run this command inside the Flipper repository itself!). +Before running this command, make sure Flipper is closed. + +For example: ```bash mkdir ~/FlipperPlugins