diff --git a/programs/create/steps/install-dependencies.ts b/programs/create/steps/install-dependencies.ts index 8c7e595c..c253c5e8 100644 --- a/programs/create/steps/install-dependencies.ts +++ b/programs/create/steps/install-dependencies.ts @@ -20,6 +20,8 @@ export async function installDependencies( projectPath: string, projectName: string ) { + // In this case the node_modules directory is always created in the + // root of projectPath so no need to use cwd. const nodeModulesPath = path.join(projectPath, 'node_modules') const command = await utils.getInstallCommand() diff --git a/programs/develop/commands/commands-lib/install-dependencies.ts b/programs/develop/commands/commands-lib/install-dependencies.ts index 183c5d0c..99efbbfb 100644 --- a/programs/develop/commands/commands-lib/install-dependencies.ts +++ b/programs/develop/commands/commands-lib/install-dependencies.ts @@ -32,8 +32,8 @@ function getInstallArgs() { return ['install' /*, '--silent' */] } -export async function installDependencies(projectPath: string) { - const nodeModulesPath = path.join(projectPath, 'node_modules') +export async function installDependencies(_projectPath: string) { + const nodeModulesPath = path.join(process.cwd(), 'node_modules') const command = await getInstallCommand() const dependenciesArgs = getInstallArgs() @@ -42,7 +42,7 @@ export async function installDependencies(projectPath: string) { try { // Change to the project directory - process.chdir(projectPath) + process.chdir(process.cwd()) // Create the node_modules directory if it doesn't exist await fs.promises.mkdir(nodeModulesPath, {recursive: true}) diff --git a/programs/develop/webpack/plugin-css/css-tools/less.ts b/programs/develop/webpack/plugin-css/css-tools/less.ts index 04dd2154..d2689cbf 100644 --- a/programs/develop/webpack/plugin-css/css-tools/less.ts +++ b/programs/develop/webpack/plugin-css/css-tools/less.ts @@ -50,7 +50,7 @@ export async function maybeUseLess( try { require.resolve('less-loader') } catch (e) { - const projectName = require(path.join(projectPath, 'package.json')).name + const projectName = require(path.join(process.cwd(), 'package.json')).name const lessDependencies = ['less', 'less-loader', 'resolve-url-loader'] diff --git a/programs/develop/webpack/plugin-css/css-tools/postcss.ts b/programs/develop/webpack/plugin-css/css-tools/postcss.ts index a65ee842..3022fcb9 100644 --- a/programs/develop/webpack/plugin-css/css-tools/postcss.ts +++ b/programs/develop/webpack/plugin-css/css-tools/postcss.ts @@ -50,7 +50,7 @@ export function isUsingPostCss(projectPath: string): boolean { } for (const configFile of postCssConfigFiles) { - if (fs.existsSync(path.join(projectPath, configFile))) { + if (fs.existsSync(path.join(process.cwd(), configFile))) { if (!userMessageDelivered) { if (process.env.EXTENSION_ENV === 'development') { console.log(messages.isUsingIntegration(manifestName, 'PostCSS')) @@ -88,7 +88,7 @@ export async function maybeUsePostCss( try { require.resolve('postcss-loader') } catch (e) { - const projectName = require(path.join(projectPath, 'package.json')).name + const projectName = require(path.join(process.cwd(), 'package.json')).name // SASS and LESS will install PostCSS as a dependency // so we don't need to check for it here. diff --git a/programs/develop/webpack/plugin-css/css-tools/sass.ts b/programs/develop/webpack/plugin-css/css-tools/sass.ts index d5718915..d19fbf17 100644 --- a/programs/develop/webpack/plugin-css/css-tools/sass.ts +++ b/programs/develop/webpack/plugin-css/css-tools/sass.ts @@ -56,7 +56,7 @@ export async function maybeUseSass( 'postcss-preset-env', 'postcss-normalize' ] - const projectName = require(path.join(projectPath, 'package.json')).name + const projectName = require(path.join(process.cwd(), 'package.json')).name await installOptionalDependencies( projectName, diff --git a/programs/develop/webpack/plugin-css/css-tools/stylelint.ts b/programs/develop/webpack/plugin-css/css-tools/stylelint.ts index 6d3e671a..77247572 100644 --- a/programs/develop/webpack/plugin-css/css-tools/stylelint.ts +++ b/programs/develop/webpack/plugin-css/css-tools/stylelint.ts @@ -48,7 +48,7 @@ export function isUsingStylelint(projectPath: string) { return false } - const configFile = getStylelintConfigFile(projectPath) + const configFile = getStylelintConfigFile(process.cwd()) const isUsingStylelint = !!configFile if (isUsingStylelint) { diff --git a/programs/develop/webpack/plugin-css/css-tools/tailwind.ts b/programs/develop/webpack/plugin-css/css-tools/tailwind.ts index af99b710..513f1bcc 100644 --- a/programs/develop/webpack/plugin-css/css-tools/tailwind.ts +++ b/programs/develop/webpack/plugin-css/css-tools/tailwind.ts @@ -22,7 +22,7 @@ export function isUsingTailwind(projectPath: string) { return false } - const configFile = getTailwindConfigFile(projectPath) + const configFile = getTailwindConfigFile(process.cwd()) const packageJson = require(packageJsonPath) const tailwindAsDevDep = @@ -60,7 +60,7 @@ export function getTailwindConfigFile(projectPath: string) { } export async function maybeUseTailwind(projectPath: string) { - const projectName = require(path.join(projectPath, 'package.json')).name + const projectName = require(path.join(process.cwd(), 'package.json')).name if (!isUsingTailwind(projectPath)) return [] try { diff --git a/programs/develop/webpack/plugin-extension/feature-html/steps/handle-common-errors.ts b/programs/develop/webpack/plugin-extension/feature-html/steps/handle-common-errors.ts index 08770263..4975da6a 100644 --- a/programs/develop/webpack/plugin-extension/feature-html/steps/handle-common-errors.ts +++ b/programs/develop/webpack/plugin-extension/feature-html/steps/handle-common-errors.ts @@ -79,7 +79,7 @@ export class HandleCommonErrors { } }) } - ) + ) } ) } diff --git a/programs/develop/webpack/plugin-js-frameworks/js-tools/babel.ts b/programs/develop/webpack/plugin-js-frameworks/js-tools/babel.ts index 84e0d052..4663ba62 100644 --- a/programs/develop/webpack/plugin-js-frameworks/js-tools/babel.ts +++ b/programs/develop/webpack/plugin-js-frameworks/js-tools/babel.ts @@ -44,7 +44,7 @@ export function isUsingBabel(projectPath: string): boolean { const isUsingBabel = babelConfigFiles.some((file) => - fs.existsSync(path.join(projectPath, file)) + fs.existsSync(path.join(process.cwd(), file)) ) || !!babelAsDevDep || !!babelAsDep diff --git a/programs/develop/webpack/plugin-js-frameworks/js-tools/typescript.ts b/programs/develop/webpack/plugin-js-frameworks/js-tools/typescript.ts index 2d5f4b9a..a1c759c8 100644 --- a/programs/develop/webpack/plugin-js-frameworks/js-tools/typescript.ts +++ b/programs/develop/webpack/plugin-js-frameworks/js-tools/typescript.ts @@ -22,7 +22,7 @@ export function isUsingTypeScript(projectPath: string) { return false } - const configFile = getUserTypeScriptConfigFile(projectPath) + const configFile = getUserTypeScriptConfigFile(process.cwd()) const packageJson = require(packageJsonPath) const manifest = require(path.join(projectPath, 'manifest.json')) const manifestName = manifest.name || 'Extension.js' @@ -40,7 +40,7 @@ export function isUsingTypeScript(projectPath: string) { } } else { console.log(messages.creatingTSConfig(manifest)) - writeTsConfig(projectPath) + writeTsConfig(process.cwd()) } } @@ -63,8 +63,6 @@ export function defaultTypeScriptConfig(projectPath: string, _opts?: any) { // Issue an error if a program tries to include a file by a casing // different from the casing on disk. forceConsistentCasingInFileNames: true, - // Report errors on unused local variables. - // inlineSources: false, // Controls how JSX constructs are emitted in JavaScript files. // This only affects output of JS files that started in .tsx files. jsx: isUsingJSFramework(projectPath) ? 'react-jsx' : 'preserve', @@ -75,10 +73,7 @@ export function defaultTypeScriptConfig(projectPath: string, _opts?: any) { moduleResolution: 'node', // Use ES modules, which are the standard in modern browsers module: 'esnext', - // Report errors on unused local variables. - // noUnusedLocals: false, - // Report errors on unused parameters in functions. - // noUnusedParameters: false, + noEmit: true, // Allow importing '.json' files resolveJsonModule: true, // Enable all strict type-checking options @@ -87,9 +82,10 @@ export function defaultTypeScriptConfig(projectPath: string, _opts?: any) { target: 'esnext', // Ensure each file can be safely transpiled without relying // on other imports - isolatedModules: false, + isolatedModules: true, skipLibCheck: true }, + include: ['**/*.ts', '**/*.tsx'], exclude: ['node_modules', 'dist'] } }