Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ghost' gulp+rollup preset): fix compatibility with yarn2/3 #131

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/presets/ghost-gulp-rollup/get-template-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ function getConfigTemplateFiles(
templateDirectory: string,
): Record<TargetFilePath, TemplateFilePath> {
const configFileNames = [
'rollup.config.js',
'README.md',
'.editorconfig',
'.nvmrc',
'.gitignore',
'gulpfile.js',
'.gulp.json',
'.nvmrc',
'foundryconfig.json',
'gulpfile.cjs',
'README.md',
'rollup.config.cjs',
];

if (useTesting) {
Expand Down Expand Up @@ -79,7 +80,7 @@ function getTestTemplateFiles({ useTypeScript, useTesting }: GhostGulpRollupOpti
const testTemplateFiles: [string, string][] = [[`example.test.${useTypeScript ? 'ts' : 'js'}`, 'example.test.njk']];

if (useTypeScript) {
testTemplateFiles.push(['tsconfig.test.json', 'tsconfig.test.json.njk']);
testTemplateFiles.push(['tsconfig.json', 'tsconfig.json.njk']);
}
return Object.fromEntries(
testTemplateFiles.map((pair) => [path.join('test', pair[0]), path.join(templateDirectory, 'test', pair[1])]),
Expand Down
1 change: 1 addition & 0 deletions src/presets/ghost-gulp-rollup/ghost-gulp-rollup-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class GhostGulpRollupPreset implements Preset {
devDependencies = devDependencies.concat([
'@league-of-foundry-developers/foundry-vtt-types',
'@rollup/plugin-typescript',
'tslib',
'typescript',
]);
}
Expand Down
3 changes: 2 additions & 1 deletion template/ghost-gulp-rollup/.eslintrc.cjs.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module.exports = {

{% endif %} parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
sourceType: 'module',{% if useTypeScript %}
project: './tsconfig.eslint.json',{% endif %}
},

env: {
Expand Down
5 changes: 5 additions & 0 deletions template/ghost-gulp-rollup/.gulp.json.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"flags": {
"gulpfile": "gulpfile.cjs"
}
}
2 changes: 2 additions & 0 deletions template/ghost-gulp-rollup/.prettierignore.njk
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
dist
package-lock.json
.pnp.cjs
.pnp.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import fs from 'fs-extra';
import gulp from 'gulp';{% if styleType == 'less' %}
import less from 'gulp-less';{% elif styleType == 'scss' %}
import sass from 'gulp-dart-sass';{% endif %}
import sourcemaps from 'gulp-sourcemaps';
import path from 'node:path';
import buffer from 'vinyl-buffer';
import source from 'vinyl-source-stream';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const fs = require('fs-extra');
const gulp = require('gulp');{% if styleType == 'less' %}
const less = require('gulp-less');{% elif styleType == 'scss' %}
const sass = require('gulp-dart-sass');{% endif %}
const sourcemaps = require('gulp-sourcemaps');
const path = require('node:path');
const buffer = require('vinyl-buffer');
const source = require('vinyl-source-stream');
const yargs = require('yargs');
const { hideBin } = require('yargs/helpers');

import rollupStream from '@rollup/stream';
const rollupStream = require('@rollup/stream');

import rollupConfig from './rollup.config.js';
const rollupConfig = require('./rollup.config.cjs');

/********************/
/* CONFIGURATION */
Expand Down Expand Up @@ -71,7 +71,7 @@ async function copyFiles() {
/**
* Watch for changes for each build step
*/
export function watch() {
function watch() {
gulp.watch(`${sourceDirectory}/**/*.${sourceFileExtension}`, { ignoreInitial: false }, buildCode);
gulp.watch(`${stylesDirectory}/**/*.${stylesExtension}`, { ignoreInitial: false }, buildStyles);
gulp.watch(
Expand All @@ -81,7 +81,7 @@ export function watch() {
);
}

export const build = gulp.series(clean, gulp.parallel(buildCode, buildStyles, copyFiles));
const build = gulp.series(clean, gulp.parallel(buildCode, buildStyles, copyFiles));

/********************/
/* CLEAN */
Expand All @@ -90,7 +90,7 @@ export const build = gulp.series(clean, gulp.parallel(buildCode, buildStyles, co
/**
* Remove built files from `dist` folder while ignoring source files
*/
export async function clean() {
async function clean() {
const files = [...staticFiles, 'module'];

if (fs.existsSync(`${stylesDirectory}/${name}.${stylesExtension}`)) {
Expand Down Expand Up @@ -129,7 +129,7 @@ function getDataPath() {
/**
* Link build to User Data folder
*/
export async function link() {
async function link() {
let destinationDirectory;
if (fs.existsSync(path.resolve(sourceDirectory, '{{ type }}.json'))) {
destinationDirectory = '{{ type }}s';
Expand All @@ -156,3 +156,10 @@ export async function link() {
await fs.symlink(path.resolve(distDirectory), linkDirectory);
}
}

module.exports = {
watch,
build,
clean,
link
};
2 changes: 1 addition & 1 deletion template/ghost-gulp-rollup/jest.config.js.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default {
{% endif %} testEnvironment: 'node',{% if useTypeScript %}
globals: {
'ts-jest': {
tsconfig: '<rootDir>/test/tsconfig.test.json',
tsconfig: '<rootDir>/test/tsconfig.json',
},
},{% endif %}
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% if useTypeScript %}import typescript from '@rollup/plugin-typescript';
{% endif %}import { nodeResolve } from '@rollup/plugin-node-resolve';
{% if useTypeScript %}const typescript = require('@rollup/plugin-typescript');
{% endif %}const { nodeResolve } = require ('@rollup/plugin-node-resolve');

export default () => ({
module.exports = () => ({
input: 'src/module/{{ name }}.{% if useTypeScript %}ts{% else %}js{% endif %}',
output: {
dir: 'dist/module',
Expand Down
2 changes: 1 addition & 1 deletion template/ghost-gulp-rollup/tsconfig.eslint.json.njk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src", {% if useTesting %}"test", {% endif %}"*.js", "*.cjs"]
"include": ["src", {% if useTesting %}"test", {% endif %}"*.js", "*.cjs", ".*.js", ".*.cjs"]
}