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 root level directory copy #174

Merged
merged 10 commits into from
Oct 7, 2024
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
node_modules
pnpm-lock.yaml
Binary file modified dist/bin/theme
Binary file not shown.
23 changes: 20 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112770,6 +112770,15 @@ const getIgnoredAssets = (id, patterns) => shopify_awaiter(void 0, void 0, void
});
const getPreviewURL = (id) => `https://${shopify_environment.store}?preview_theme_id=${id}`;
const getCustomizeURL = (id) => `https://${shopify_environment.store}/admin/themes/${id}/editor`;
const themeDirectories = [
'assets',
'config',
'layout',
'locales',
'sections',
'snippets',
'templates',
];

// EXTERNAL MODULE: ./node_modules/.pnpm/fs-extra@11.2.0/node_modules/fs-extra/lib/index.js
var lib = __nccwpck_require__(99863);
Expand All @@ -112789,15 +112798,23 @@ var build_from_environment_awaiter = (undefined && undefined.__awaiter) || funct




/* harmony default export */ const build_from_environment = (() => build_from_environment_awaiter(void 0, void 0, void 0, function* () {
var _a;
const environment = helpers_config[THEME_KIT_ENVIRONMENT];
const themeId = parseInt(environment.theme_id, 10);
const ignoredFiles = environment.ignore_files;
const directory = (_a = environment.directory) !== null && _a !== void 0 ? _a : './';
if (themeDirectories.includes(BUILD_DIR)) {
core.error('BUILD_DIR cannot be the same as one of the default Shopify theme directories');
}
// Copy existing source directory
core.info(`Copying directory "${environment.directory}" to "${BUILD_DIR}"`);
core.info(`Copying directory "${directory}" to "${BUILD_DIR}"`);
lib_default().emptyDirSync(BUILD_DIR);
lib_default().copySync(environment.directory, BUILD_DIR, {
filter: (src) => !src.includes('node_modules'),
themeDirectories.forEach((themeDirectory) => {
lib_default().copySync(external_path_default().join(directory, themeDirectory), external_path_default().join(BUILD_DIR, themeDirectory), {
filter: (src) => !src.includes('node_modules'),
});
});
// Copy ignored files from environment
if (environment.ignore_files) {
Expand Down
22 changes: 18 additions & 4 deletions src/actions/parts/build-from-environment.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
import * as core from '@actions/core';
import fs from 'fs-extra';
import path from 'path';
import config from '../../helpers/config';
import { BUILD_DIR, THEME_KIT_ENVIRONMENT } from '../../inputs';
import { getIgnoredAssets } from '../../helpers/shopify';
import { getIgnoredAssets, themeDirectories } from '../../helpers/shopify';

export default async (): Promise<void> => {
const environment = config[THEME_KIT_ENVIRONMENT];
const themeId = parseInt(environment.theme_id, 10);
const ignoredFiles = environment.ignore_files;
const directory = environment.directory ?? './';

if (themeDirectories.includes(BUILD_DIR)) {
core.error(
'BUILD_DIR cannot be the same as one of the default Shopify theme directories',
);
}

// Copy existing source directory
core.info(`Copying directory "${environment.directory}" to "${BUILD_DIR}"`);
core.info(`Copying directory "${directory}" to "${BUILD_DIR}"`);

fs.emptyDirSync(BUILD_DIR);
fs.copySync(environment.directory, BUILD_DIR, {
filter: (src) => !src.includes('node_modules'),
themeDirectories.forEach((themeDirectory) => {
fs.copySync(
path.join(directory, themeDirectory),
path.join(BUILD_DIR, themeDirectory),
{
filter: (src) => !src.includes('node_modules'),
},
);
});

// Copy ignored files from environment
Expand Down
10 changes: 10 additions & 0 deletions src/helpers/shopify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,13 @@ export const getPreviewURL = (id: number) =>

export const getCustomizeURL = (id: number) =>
`https://${environment.store}/admin/themes/${id}/editor`;

export const themeDirectories = [
'assets',
'config',
'layout',
'locales',
'sections',
'snippets',
'templates',
];