create-expo-module 0.8.2 → 0.8.3
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/build/createExampleApp.js +17 -4
- package/build/createExampleApp.js.map +1 -1
- package/build/packageManager.d.ts +2 -1
- package/build/packageManager.js +8 -4
- package/build/packageManager.js.map +1 -1
- package/package.json +2 -2
- package/src/createExampleApp.ts +18 -7
- package/src/packageManager.ts +9 -4
|
@@ -33,10 +33,23 @@ async function createExampleApp(data, targetDir, packageManager) {
|
|
|
33
33
|
const templateVersion = EXPO_BETA ? 'next' : 'latest';
|
|
34
34
|
const template = `expo-template-blank-typescript@${templateVersion}`;
|
|
35
35
|
debug(`Using example template: ${template}`);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const command = [
|
|
37
|
+
'create',
|
|
38
|
+
'expo-app',
|
|
39
|
+
'--',
|
|
40
|
+
exampleProjectSlug,
|
|
41
|
+
'--template',
|
|
42
|
+
template,
|
|
43
|
+
'--yes',
|
|
44
|
+
];
|
|
45
|
+
try {
|
|
46
|
+
await (0, spawn_async_1.default)(packageManager, command, {
|
|
47
|
+
cwd: targetDir,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`${command.join(' ')} failed with exit code: ${error?.status}.\n\nError stack:\n${error?.stderr}`);
|
|
52
|
+
}
|
|
40
53
|
step.succeed('Initialized the example app');
|
|
41
54
|
});
|
|
42
55
|
await (0, ora_1.newStep)('Configuring the example app', async (step) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExampleApp.js","sourceRoot":"","sources":["../src/createExampleApp.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAC3C,wDAA0B;AAC1B,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AAExB,qDAAuD;AAGvD,qCAAsC;AAEtC,MAAM,KAAK,GAAG,OAAO,CAAC,O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CAAC,IAAI,GAAG,EAAE,CAAC;KACvB;IAED,iDAAiD;IACjD,0DAA0D;IAC1D,WAAW,CAAC,IAAI,CAAC,WAAW,GAAG;QAC7B,gBAAgB,EAAE,IAAI;KACvB,CAAC;IAEF,kCAAkC;IAClC,KAAK,MAAM,kBAAkB,IAAI,sBAAsB,EAAE;QACvD,OAAO,WAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;KACrD;IAED,MAAM,kBAAE,CAAC,SAAS,CAAC,eAAe,EAAE,WAAW,EAAE;QAC/C,MAAM,EAAE,CAAC;KACV,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,kBAAkB,CAAC,cAAsB;IACtD,MAAM,IAAA,aAAO,EAAC,6BAA6B,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC1D,MAAM,IAAA,qBAAU,EAAC,KAAK,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE;YAC5D,GAAG,EAAE,cAAc;YACnB,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;SACpC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,UAAU,CAAC,OAAe;IACvC,MAAM,IAAA,qBAAU,EAAC,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE;QACnC,GAAG,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAC9B,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;KACpC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport fs from 'fs-extra';\nimport getenv from 'getenv';\nimport os from 'os';\nimport path from 'path';\n\nimport { installDependencies } from './packageManager';\nimport { PackageManagerName } from './resolvePackageManager';\nimport { SubstitutionData } from './types';\nimport { newStep } from './utils/ora';\n\nconst debug = require('debug')('create-expo-module:createExampleApp') as typeof console.log;\n\n// These dependencies will be removed from the example app (`expo init` adds them)\nconst DEPENDENCIES_TO_REMOVE = ['expo-status-bar', 'expo-splash-screen'];\nconst EXPO_BETA = getenv.boolish('EXPO_BETA', false);\n\n/**\n * Initializes a new Expo project as an example app.\n */\nexport async function createExampleApp(\n data: SubstitutionData,\n targetDir: string,\n packageManager: PackageManagerName\n): Promise<void> {\n // Package name for the example app\n const exampleProjectSlug = `${data.project.slug}-example`;\n\n // `expo init` creates a new folder with the same name as the project slug\n const appTmpPath = path.join(targetDir, exampleProjectSlug);\n\n // Path to the target example dir\n const appTargetPath = path.join(targetDir, 'example');\n\n if (!(await fs.pathExists(appTargetPath))) {\n // The template doesn't include the example app, so just skip this phase\n return;\n }\n\n await newStep('Initializing the example app', async (step) => {\n const templateVersion = EXPO_BETA ? 'next' : 'latest';\n const template = `expo-template-blank-typescript@${templateVersion}`;\n debug(`Using example template: ${template}`);\n await spawnAsync(\n packageManager,\n ['create', 'expo-app', '--', exampleProjectSlug, '--template', template, '--yes'],\n {\n cwd: targetDir,\n stdio: 'ignore',\n }\n );\n step.succeed('Initialized the example app');\n });\n\n await newStep('Configuring the example app', async (step) => {\n // \"example\" folder already exists and contains template files,\n // that should replace these created by `expo init`.\n await moveFiles(appTargetPath, appTmpPath);\n\n // Cleanup the \"example\" dir\n await fs.rmdir(appTargetPath);\n\n // Clean up the \".git\" from example app\n // note, this directory has contents, rmdir will throw\n await fs.remove(path.join(appTmpPath, '.git'));\n\n // Move the temporary example app to \"example\" dir\n await fs.rename(appTmpPath, appTargetPath);\n\n await addMissingAppConfigFields(appTargetPath, data);\n\n step.succeed('Configured the example app');\n });\n\n await prebuildExampleApp(appTargetPath);\n\n await modifyPackageJson(appTargetPath);\n\n await newStep('Installing dependencies in the example app', async (step) => {\n await installDependencies(packageManager, appTargetPath);\n if (os.platform() === 'darwin') {\n await podInstall(appTargetPath);\n step.succeed('Installed dependencies in the example app');\n } else {\n step.succeed('Installed dependencies in the example app (skipped installing CocoaPods)');\n }\n });\n}\n\n/**\n * Copies files from one directory to another.\n */\nasync function moveFiles(fromPath: string, toPath: string): Promise<void> {\n for (const file of await fs.readdir(fromPath)) {\n await fs.move(path.join(fromPath, file), path.join(toPath, file), {\n overwrite: true,\n });\n }\n}\n\n/**\n * Adds missing configuration that are required to run `npx expo prebuild`.\n */\nasync function addMissingAppConfigFields(appPath: string, data: SubstitutionData): Promise<void> {\n const appConfigPath = path.join(appPath, 'app.json');\n const appConfig = await fs.readJson(appConfigPath);\n const appId = `${data.project.package}.example`;\n\n // Android package name needs to be added to app.json\n if (!appConfig.expo.android) {\n appConfig.expo.android = {};\n }\n appConfig.expo.android.package = appId;\n\n // Specify iOS bundle identifier\n if (!appConfig.expo.ios) {\n appConfig.expo.ios = {};\n }\n appConfig.expo.ios.bundleIdentifier = appId;\n\n await fs.writeJson(appConfigPath, appConfig, {\n spaces: 2,\n });\n}\n\n/**\n * Applies necessary changes to **package.json** of the example app.\n * It means setting the autolinking config and removing unnecessary dependencies.\n */\nasync function modifyPackageJson(appPath: string): Promise<void> {\n const packageJsonPath = path.join(appPath, 'package.json');\n const packageJson = await fs.readJson(packageJsonPath);\n\n if (!packageJson.expo) {\n packageJson.expo = {};\n }\n\n // Set the native modules dir to the root folder,\n // so that the autolinking can detect and link the module.\n packageJson.expo.autolinking = {\n nativeModulesDir: '..',\n };\n\n // Remove unnecessary dependencies\n for (const dependencyToRemove of DEPENDENCIES_TO_REMOVE) {\n delete packageJson.dependencies[dependencyToRemove];\n }\n\n await fs.writeJson(packageJsonPath, packageJson, {\n spaces: 2,\n });\n}\n\n/**\n * Runs `npx expo prebuild` in the example app.\n */\nasync function prebuildExampleApp(exampleAppPath: string): Promise<void> {\n await newStep('Prebuilding the example app', async (step) => {\n await spawnAsync('npx', ['expo', 'prebuild', '--no-install'], {\n cwd: exampleAppPath,\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n step.succeed('Prebuilt the example app');\n });\n}\n\n/**\n * Runs `pod install` in the iOS project at the given path.\n */\nasync function podInstall(appPath: string): Promise<void> {\n await spawnAsync('pod', ['install'], {\n cwd: path.join(appPath, 'ios'),\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createExampleApp.js","sourceRoot":"","sources":["../src/createExampleApp.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAC3C,wDAA0B;AAC1B,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AAExB,qDAAuD;AAGvD,qCAAsC;AAEtC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,qCAAqC,CAAuB,CAAC;AAE5F,kFAAkF;AAClF,MAAM,sBAAsB,GAAG,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AACzE,MAAM,SAAS,GAAG,gBAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAErD;;GAEG;AACI,KAAK,UAAU,gBAAgB,CACpC,IAAsB,EACtB,SAAiB,EACjB,cAAkC;IAElC,mCAAmC;IACnC,MAAM,kBAAkB,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC;IAE1D,0EAA0E;IAC1E,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAE5D,iCAAiC;IACjC,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAEtD,IAAI,CAAC,CAAC,MAAM,kBAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAAE;QACzC,wEAAwE;QACxE,OAAO;KACR;IAED,MAAM,IAAA,aAAO,EAAC,8BAA8B,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3D,MAAM,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAA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AE,cAAc;YACnB,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;SACpC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,UAAU,CAAC,OAAe;IACvC,MAAM,IAAA,qBAAU,EAAC,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE;QACnC,GAAG,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAC9B,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;KACpC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport fs from 'fs-extra';\nimport getenv from 'getenv';\nimport os from 'os';\nimport path from 'path';\n\nimport { installDependencies } from './packageManager';\nimport { PackageManagerName } from './resolvePackageManager';\nimport { SubstitutionData } from './types';\nimport { newStep } from './utils/ora';\n\nconst debug = require('debug')('create-expo-module:createExampleApp') as typeof console.log;\n\n// These dependencies will be removed from the example app (`expo init` adds them)\nconst DEPENDENCIES_TO_REMOVE = ['expo-status-bar', 'expo-splash-screen'];\nconst EXPO_BETA = getenv.boolish('EXPO_BETA', false);\n\n/**\n * Initializes a new Expo project as an example app.\n */\nexport async function createExampleApp(\n data: SubstitutionData,\n targetDir: string,\n packageManager: PackageManagerName\n): Promise<void> {\n // Package name for the example app\n const exampleProjectSlug = `${data.project.slug}-example`;\n\n // `expo init` creates a new folder with the same name as the project slug\n const appTmpPath = path.join(targetDir, exampleProjectSlug);\n\n // Path to the target example dir\n const appTargetPath = path.join(targetDir, 'example');\n\n if (!(await fs.pathExists(appTargetPath))) {\n // The template doesn't include the example app, so just skip this phase\n return;\n }\n\n await newStep('Initializing the example app', async (step) => {\n const templateVersion = EXPO_BETA ? 'next' : 'latest';\n const template = `expo-template-blank-typescript@${templateVersion}`;\n debug(`Using example template: ${template}`);\n const command = [\n 'create',\n 'expo-app',\n '--',\n exampleProjectSlug,\n '--template',\n template,\n '--yes',\n ];\n try {\n await spawnAsync(packageManager, command, {\n cwd: targetDir,\n });\n } catch (error: any) {\n throw new Error(\n `${command.join(' ')} failed with exit code: ${error?.status}.\\n\\nError stack:\\n${error?.stderr}`\n );\n }\n\n step.succeed('Initialized the example app');\n });\n\n await newStep('Configuring the example app', async (step) => {\n // \"example\" folder already exists and contains template files,\n // that should replace these created by `expo init`.\n await moveFiles(appTargetPath, appTmpPath);\n\n // Cleanup the \"example\" dir\n await fs.rmdir(appTargetPath);\n\n // Clean up the \".git\" from example app\n // note, this directory has contents, rmdir will throw\n await fs.remove(path.join(appTmpPath, '.git'));\n\n // Move the temporary example app to \"example\" dir\n await fs.rename(appTmpPath, appTargetPath);\n\n await addMissingAppConfigFields(appTargetPath, data);\n\n step.succeed('Configured the example app');\n });\n\n await prebuildExampleApp(appTargetPath);\n\n await modifyPackageJson(appTargetPath);\n\n await newStep('Installing dependencies in the example app', async (step) => {\n await installDependencies(packageManager, appTargetPath);\n if (os.platform() === 'darwin') {\n await podInstall(appTargetPath);\n step.succeed('Installed dependencies in the example app');\n } else {\n step.succeed('Installed dependencies in the example app (skipped installing CocoaPods)');\n }\n });\n}\n\n/**\n * Copies files from one directory to another.\n */\nasync function moveFiles(fromPath: string, toPath: string): Promise<void> {\n for (const file of await fs.readdir(fromPath)) {\n await fs.move(path.join(fromPath, file), path.join(toPath, file), {\n overwrite: true,\n });\n }\n}\n\n/**\n * Adds missing configuration that are required to run `npx expo prebuild`.\n */\nasync function addMissingAppConfigFields(appPath: string, data: SubstitutionData): Promise<void> {\n const appConfigPath = path.join(appPath, 'app.json');\n const appConfig = await fs.readJson(appConfigPath);\n const appId = `${data.project.package}.example`;\n\n // Android package name needs to be added to app.json\n if (!appConfig.expo.android) {\n appConfig.expo.android = {};\n }\n appConfig.expo.android.package = appId;\n\n // Specify iOS bundle identifier\n if (!appConfig.expo.ios) {\n appConfig.expo.ios = {};\n }\n appConfig.expo.ios.bundleIdentifier = appId;\n\n await fs.writeJson(appConfigPath, appConfig, {\n spaces: 2,\n });\n}\n\n/**\n * Applies necessary changes to **package.json** of the example app.\n * It means setting the autolinking config and removing unnecessary dependencies.\n */\nasync function modifyPackageJson(appPath: string): Promise<void> {\n const packageJsonPath = path.join(appPath, 'package.json');\n const packageJson = await fs.readJson(packageJsonPath);\n\n if (!packageJson.expo) {\n packageJson.expo = {};\n }\n\n // Set the native modules dir to the root folder,\n // so that the autolinking can detect and link the module.\n packageJson.expo.autolinking = {\n nativeModulesDir: '..',\n };\n\n // Remove unnecessary dependencies\n for (const dependencyToRemove of DEPENDENCIES_TO_REMOVE) {\n delete packageJson.dependencies[dependencyToRemove];\n }\n\n await fs.writeJson(packageJsonPath, packageJson, {\n spaces: 2,\n });\n}\n\n/**\n * Runs `npx expo prebuild` in the example app.\n */\nasync function prebuildExampleApp(exampleAppPath: string): Promise<void> {\n await newStep('Prebuilding the example app', async (step) => {\n await spawnAsync('npx', ['expo', 'prebuild', '--no-install'], {\n cwd: exampleAppPath,\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n step.succeed('Prebuilt the example app');\n });\n}\n\n/**\n * Runs `pod install` in the iOS project at the given path.\n */\nasync function podInstall(appPath: string): Promise<void> {\n await spawnAsync('pod', ['install'], {\n cwd: path.join(appPath, 'ios'),\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n}\n"]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import spawnAsync from '@expo/spawn-async';
|
|
1
2
|
import { PackageManagerName } from './resolvePackageManager';
|
|
2
|
-
export declare function installDependencies(packageManager: PackageManagerName, appPath: string, ...args: string[]): Promise<
|
|
3
|
+
export declare function installDependencies(packageManager: PackageManagerName, appPath: string, ...args: string[]): Promise<spawnAsync.SpawnResult>;
|
package/build/packageManager.js
CHANGED
|
@@ -6,10 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.installDependencies = void 0;
|
|
7
7
|
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
|
|
8
8
|
async function installDependencies(packageManager, appPath, ...args) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
try {
|
|
10
|
+
return await (0, spawn_async_1.default)(packageManager, ['install', ...args], {
|
|
11
|
+
cwd: appPath,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
throw new Error(`${packageManager} install exited with non-zero code: ${error?.status}\n\nError stack:\n${error?.stderr}`);
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
exports.installDependencies = installDependencies;
|
|
15
19
|
//# sourceMappingURL=packageManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageManager.js","sourceRoot":"","sources":["../src/packageManager.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAIpC,KAAK,UAAU,mBAAmB,CACvC,cAAkC,EAClC,OAAe,EACf,GAAG,IAAc;IAEjB,MAAM,IAAA,qBAAU,EAAC,cAAc,EAAE,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"packageManager.js","sourceRoot":"","sources":["../src/packageManager.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAIpC,KAAK,UAAU,mBAAmB,CACvC,cAAkC,EAClC,OAAe,EACf,GAAG,IAAc;IAEjB,IAAI;QACF,OAAO,MAAM,IAAA,qBAAU,EAAC,cAAc,EAAE,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,EAAE;YAC5D,GAAG,EAAE,OAAO;SACb,CAAC,CAAC;KACJ;IAAC,OAAO,KAAU,EAAE;QACnB,MAAM,IAAI,KAAK,CACb,GAAG,cAAc,uCAAuC,KAAK,EAAE,MAAM,qBAAqB,KAAK,EAAE,MAAM,EAAE,CAC1G,CAAC;KACH;AACH,CAAC;AAdD,kDAcC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\n\nimport { PackageManagerName } from './resolvePackageManager';\n\nexport async function installDependencies(\n packageManager: PackageManagerName,\n appPath: string,\n ...args: string[]\n) {\n try {\n return await spawnAsync(packageManager, ['install', ...args], {\n cwd: appPath,\n });\n } catch (error: any) {\n throw new Error(\n `${packageManager} install exited with non-zero code: ${error?.status}\\n\\nError stack:\\n${error?.stderr}`\n );\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-expo-module",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "The script to create the Expo module",
|
|
5
5
|
"main": "build/create-expo-module.js",
|
|
6
6
|
"types": "build/create-expo-module.d.ts",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"@types/prompts": "^2.4.9",
|
|
58
58
|
"expo-module-scripts": "^4.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "1f84b4c952ed9785c41ee65c9877e44f1df27af9"
|
|
61
61
|
}
|
package/src/createExampleApp.ts
CHANGED
|
@@ -41,14 +41,25 @@ export async function createExampleApp(
|
|
|
41
41
|
const templateVersion = EXPO_BETA ? 'next' : 'latest';
|
|
42
42
|
const template = `expo-template-blank-typescript@${templateVersion}`;
|
|
43
43
|
debug(`Using example template: ${template}`);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const command = [
|
|
45
|
+
'create',
|
|
46
|
+
'expo-app',
|
|
47
|
+
'--',
|
|
48
|
+
exampleProjectSlug,
|
|
49
|
+
'--template',
|
|
50
|
+
template,
|
|
51
|
+
'--yes',
|
|
52
|
+
];
|
|
53
|
+
try {
|
|
54
|
+
await spawnAsync(packageManager, command, {
|
|
48
55
|
cwd: targetDir,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
});
|
|
57
|
+
} catch (error: any) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`${command.join(' ')} failed with exit code: ${error?.status}.\n\nError stack:\n${error?.stderr}`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
52
63
|
step.succeed('Initialized the example app');
|
|
53
64
|
});
|
|
54
65
|
|
package/src/packageManager.ts
CHANGED
|
@@ -7,8 +7,13 @@ export async function installDependencies(
|
|
|
7
7
|
appPath: string,
|
|
8
8
|
...args: string[]
|
|
9
9
|
) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
try {
|
|
11
|
+
return await spawnAsync(packageManager, ['install', ...args], {
|
|
12
|
+
cwd: appPath,
|
|
13
|
+
});
|
|
14
|
+
} catch (error: any) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`${packageManager} install exited with non-zero code: ${error?.status}\n\nError stack:\n${error?.stderr}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
14
19
|
}
|