mirror of
https://github.com/strapi/strapi.git
synced 2025-12-01 09:35:26 +00:00
isTypeScriptProject -> isUsingTypeScript
This commit is contained in:
parent
831726978a
commit
54fefcf5d2
@ -11,10 +11,10 @@ module.exports = async ({ optimization, forceBuild = true }) => {
|
||||
let buildDestDir = process.cwd();
|
||||
const srcDir = process.cwd();
|
||||
|
||||
const isTSProject = await tsUtils.isTypeScriptProject(srcDir);
|
||||
const useTypeScriptServer = await tsUtils.isUsingTypeScript(srcDir);
|
||||
|
||||
// Typescript
|
||||
if (isTSProject) {
|
||||
if (useTypeScriptServer) {
|
||||
await buildTypeScript({ srcDir, watch: false });
|
||||
|
||||
// Update the dir path for the next steps
|
||||
@ -24,7 +24,8 @@ module.exports = async ({ optimization, forceBuild = true }) => {
|
||||
await buildAdmin({
|
||||
buildDestDir,
|
||||
forceBuild,
|
||||
isTSProject,
|
||||
// TODO: Delegate the is-ts-project check to the admin
|
||||
isTSProject: useTypeScriptServer,
|
||||
optimization,
|
||||
srcDir,
|
||||
});
|
||||
|
||||
@ -12,8 +12,10 @@ const getEnabledPlugins = require('../../core/loaders/plugins/get-enabled-plugin
|
||||
|
||||
module.exports = async ({ buildDestDir, forceBuild = true, isTSProject, optimization, srcDir }) => {
|
||||
const strapiInstance = strapi({
|
||||
// TODO check if this is working @convly
|
||||
// Directories
|
||||
appDir: srcDir,
|
||||
distDir: buildDestDir,
|
||||
// Options
|
||||
autoReload: true,
|
||||
serveAdminPanel: false,
|
||||
});
|
||||
|
||||
@ -5,8 +5,8 @@ const fs = require('fs-extra');
|
||||
const tsUtils = require('@strapi/typescript-utils');
|
||||
|
||||
const cleanupDistDirectory = async distDir => {
|
||||
if (!await fs.pathExists(distDir)){
|
||||
return
|
||||
if (!(await fs.pathExists(distDir))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dirContent = await fs.readdir(distDir);
|
||||
@ -14,21 +14,18 @@ const cleanupDistDirectory = async distDir => {
|
||||
// Ignore the admin build folder
|
||||
.filter(filename => filename !== 'build');
|
||||
|
||||
|
||||
for (const filename of validFilenames) {
|
||||
await fs.remove(path.resolve(distDir, filename));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = async ({ srcDir, distDir, watch = false }) => {
|
||||
const isTSProject = await tsUtils.isTypeScriptProject(srcDir);
|
||||
const isTSProject = await tsUtils.isUsingTypeScript(srcDir);
|
||||
|
||||
if (!isTSProject) {
|
||||
throw new Error(`tsconfig file not found in ${srcDir}`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
await cleanupDistDirectory(distDir);
|
||||
|
||||
return tsUtils.compile(srcDir, { watch });
|
||||
|
||||
@ -21,7 +21,7 @@ const { buildTypeScript, buildAdmin } = require('./builders');
|
||||
module.exports = async function({ build, watchAdmin, polling, browser }) {
|
||||
const appDir = process.cwd();
|
||||
|
||||
const isTSProject = await tsUtils.isTypeScriptProject(appDir);
|
||||
const isTSProject = await tsUtils.isUsingTypeScript(appDir);
|
||||
const distDir = isTSProject ? path.join(appDir, 'dist') : appDir;
|
||||
|
||||
try {
|
||||
@ -61,6 +61,7 @@ const primaryProcess = async ({ distDir, appDir, build, isTSProject, watchAdmin,
|
||||
await buildAdmin({
|
||||
buildDestDir: distDir,
|
||||
forceBuild: false,
|
||||
// TODO: delegates the is-ts-project check to the admin
|
||||
isTSProject,
|
||||
optimization: false,
|
||||
srcDir: appDir,
|
||||
|
||||
@ -12,7 +12,7 @@ const strapi = require('../index');
|
||||
module.exports = async function({ browser }) {
|
||||
const currentDirectory = process.cwd();
|
||||
|
||||
const isTSProject = await tsUtils.isTypeScriptProject(currentDirectory);
|
||||
const isTSProject = await tsUtils.isUsingTypeScript(currentDirectory);
|
||||
const buildDestDir = isTSProject ? path.join(currentDirectory, 'dist') : currentDirectory;
|
||||
|
||||
const strapiInstance = strapi({
|
||||
|
||||
@ -49,7 +49,7 @@ module.exports = plop => {
|
||||
actions(answers) {
|
||||
const filePath = answers.isPluginApi && answers.plugin ? 'plugins/{{plugin}}' : 'api/{{id}}';
|
||||
const currentDir = process.cwd();
|
||||
const language = tsUtils.isTypeScriptProjectSync(currentDir) ? 'ts' : 'js';
|
||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||
|
||||
const baseActions = [
|
||||
{
|
||||
|
||||
@ -83,7 +83,7 @@ module.exports = plop => {
|
||||
|
||||
const filePath = getFilePath(answers.destination);
|
||||
const currentDir = process.cwd();
|
||||
const language = tsUtils.isTypeScriptProjectSync(currentDir) ? 'ts' : 'js';
|
||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||
|
||||
const baseActions = [
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@ module.exports = plop => {
|
||||
actions(answers) {
|
||||
const filePath = getFilePath(answers.destination);
|
||||
const currentDir = process.cwd();
|
||||
const language = tsUtils.isTypeScriptProjectSync(currentDir) ? 'ts' : 'js';
|
||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
@ -20,7 +20,7 @@ module.exports = plop => {
|
||||
actions(answers) {
|
||||
const filePath = getFilePath(answers.destination);
|
||||
const currentDir = process.cwd();
|
||||
const language = tsUtils.isTypeScriptProjectSync(currentDir) ? 'ts' : 'js';
|
||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
@ -39,7 +39,7 @@ module.exports = plop => {
|
||||
],
|
||||
actions(answers) {
|
||||
const currentDir = process.cwd();
|
||||
const language = tsUtils.isTypeScriptProjectSync(currentDir) ? 'ts' : 'js';
|
||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||
|
||||
// TODO: Adds tsconfig & build command for TS plugins?
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ module.exports = plop => {
|
||||
actions(answers) {
|
||||
const filePath = getFilePath(answers.destination);
|
||||
const currentDir = process.cwd();
|
||||
const language = tsUtils.isTypeScriptProjectSync(currentDir) ? 'ts' : 'js';
|
||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
@ -20,7 +20,7 @@ module.exports = plop => {
|
||||
actions(answers) {
|
||||
const filePath = getFilePath(answers.destination);
|
||||
const currentDir = process.cwd();
|
||||
const language = tsUtils.isTypeScriptProjectSync(currentDir) ? 'ts' : 'js';
|
||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
const isTypeScriptProject = require('./is-typescript-project');
|
||||
const isTypeScriptProjectSync = require('./is-typescript-project-sync');
|
||||
const isUsingTypeScript = require('./is-using-typescript');
|
||||
const isUsingTypeScriptSync = require('./is-using-typescript-sync');
|
||||
const getConfigPath = require('./get-config-path');
|
||||
const reportDiagnostics = require('./report-diagnostics');
|
||||
const resolveConfigOptions = require('./resolve-config-options');
|
||||
const formatHost = require('./format-host');
|
||||
|
||||
module.exports = {
|
||||
isTypeScriptProject,
|
||||
isTypeScriptProjectSync,
|
||||
isUsingTypeScript,
|
||||
isUsingTypeScriptSync,
|
||||
getConfigPath,
|
||||
reportDiagnostics,
|
||||
resolveConfigOptions,
|
||||
|
||||
@ -5,7 +5,7 @@ const fse = require('fs-extra');
|
||||
const getConfigPath = require('./get-config-path');
|
||||
|
||||
/**
|
||||
* Checks if `dir` is a TypeScript directory (whether there is a tsconfig file or not)
|
||||
* Checks if `dir` is a using TypeScript (whether there is a tsconfig file or not)
|
||||
* @param {string} dir
|
||||
* @param {string | undefined} filename
|
||||
* @returns {boolean}
|
||||
@ -5,7 +5,7 @@ const fse = require('fs-extra');
|
||||
const getConfigPath = require('./get-config-path');
|
||||
|
||||
/**
|
||||
* Checks if `dir` is a TypeScript directory (whether there is a tsconfig file or not)
|
||||
* Checks if `dir` is a using TypeScript (whether there is a tsconfig file or not)
|
||||
* @param {string} dir
|
||||
* @param {string | undefined} filename
|
||||
* @returns {Promise<boolean>}
|
||||
Loading…
x
Reference in New Issue
Block a user