Skip to content

Commit

Permalink
Merge pull request #174 from grafikr/fix-root-directory
Browse files Browse the repository at this point in the history
Fix root level directory copy
  • Loading branch information
andershagbard authored Oct 7, 2024
2 parents 3eb53e7 + 0fc9c0d commit 68bfff5
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
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',
];

0 comments on commit 68bfff5

Please sign in to comment.