@mekari/pixel3-postcss 0.0.6 → 0.0.7-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -54,9 +54,7 @@ var init_default_config = __esm({
54
54
  preflight: true,
55
55
  presets: ["@mekari/pixel3-theme"],
56
56
  include: [
57
- "./src/**/*.{js,jsx,ts,tsx,vue}",
58
- "./node_modules/@mekari/**/dist/**/*.{js,mjs}"
59
- // Need to analyze usage of children component, MpFlex, and Pixel tag.
57
+ "./src/**/*.{js,jsx,ts,tsx,vue}"
60
58
  ],
61
59
  exclude: [],
62
60
  layers: {
@@ -92,23 +90,46 @@ var import_module = require("module");
92
90
  // src/create-config.ts
93
91
  init_cjs_shims();
94
92
  var fs = require("fs");
93
+ var path = require("path");
95
94
  var { defaultConfig: defaultConfig2 } = (init_default_config(), __toCommonJS(default_config_exports));
95
+ function findRealModulePath(moduleName) {
96
+ try {
97
+ const symlinkPath = path.join("node_modules", moduleName);
98
+ const realPath = fs.realpathSync(symlinkPath);
99
+ return realPath;
100
+ } catch (error) {
101
+ console.error("Error finding real module path:", error);
102
+ return null;
103
+ }
104
+ }
96
105
  function mergeConfig(obj1, obj2) {
97
106
  const mergeKey = ["include", "exclude"];
98
107
  const tempObj = {};
108
+ const hasReplaceConfig = obj2.replaceConfig?.length > 0;
99
109
  mergeKey.map((item) => {
100
110
  if (obj2.hasOwnProperty(item)) {
101
111
  if (item === "staticCss") {
102
112
  tempObj[item] = obj2[item];
103
113
  return;
104
114
  }
115
+ if (hasReplaceConfig && obj2.replaceConfig.includes(item)) {
116
+ tempObj[item] = obj2[item];
117
+ return;
118
+ }
105
119
  tempObj[item] = [...obj1[item], ...obj2[item]];
106
120
  }
107
121
  });
108
122
  return { ...obj1, ...tempObj };
109
123
  }
110
- var createConfigFile = (filePath, options) => {
111
- const configs = mergeConfig(defaultConfig2, options);
124
+ var createConfigFile = (filePath, options, packageManager) => {
125
+ const restDefaultConfig = { ...defaultConfig2 };
126
+ if (packageManager) {
127
+ const pixelDir = path.dirname(findRealModulePath("@mekari/pixel3"));
128
+ const extend = `${pixelDir}/**/dist/**/*.{js,mjs}`;
129
+ const finalInclude = [...restDefaultConfig.include, extend];
130
+ restDefaultConfig.include = finalInclude;
131
+ }
132
+ const configs = mergeConfig(restDefaultConfig, options);
112
133
  const data = "export default" + JSON.stringify(configs, null, 2);
113
134
  try {
114
135
  fs.writeFileSync(filePath, data, "utf-8");
@@ -140,9 +161,25 @@ var shouldSkip = (fileName) => {
140
161
  return false;
141
162
  return nodeModulesRegex.test(fileName);
142
163
  };
164
+ function getPackageManager() {
165
+ const userAgent = process.env.npm_config_user_agent;
166
+ let result = "";
167
+ if (userAgent) {
168
+ if (userAgent.includes("pnpm")) {
169
+ result = "pnpm";
170
+ } else if (userAgent.includes("npm")) {
171
+ result = "npm";
172
+ } else {
173
+ result = "yarn";
174
+ }
175
+ }
176
+ return result;
177
+ }
143
178
  var pixelcss = (options = {}) => {
144
179
  const { cwd } = options;
145
- createConfigFile(configPath, options);
180
+ const packageManager = getPackageManager();
181
+ createConfigFile(configPath, options, packageManager);
182
+ console.log("Using package manager", packageManager);
146
183
  console.log("Pixel Config (auto-generated) :", configPath);
147
184
  return {
148
185
  postcssPlugin: PLUGIN_NAME,
package/dist/index.mjs CHANGED
@@ -50,9 +50,7 @@ var init_default_config = __esm({
50
50
  preflight: true,
51
51
  presets: ["@mekari/pixel3-theme"],
52
52
  include: [
53
- "./src/**/*.{js,jsx,ts,tsx,vue}",
54
- "./node_modules/@mekari/**/dist/**/*.{js,mjs}"
55
- // Need to analyze usage of children component, MpFlex, and Pixel tag.
53
+ "./src/**/*.{js,jsx,ts,tsx,vue}"
56
54
  ],
57
55
  exclude: [],
58
56
  layers: {
@@ -78,29 +76,52 @@ var init_default_config = __esm({
78
76
  });
79
77
 
80
78
  // src/create-config.ts
79
+ function findRealModulePath(moduleName) {
80
+ try {
81
+ const symlinkPath = path.join("node_modules", moduleName);
82
+ const realPath = fs.realpathSync(symlinkPath);
83
+ return realPath;
84
+ } catch (error) {
85
+ console.error("Error finding real module path:", error);
86
+ return null;
87
+ }
88
+ }
81
89
  function mergeConfig(obj1, obj2) {
82
90
  const mergeKey = ["include", "exclude"];
83
91
  const tempObj = {};
92
+ const hasReplaceConfig = obj2.replaceConfig?.length > 0;
84
93
  mergeKey.map((item) => {
85
94
  if (obj2.hasOwnProperty(item)) {
86
95
  if (item === "staticCss") {
87
96
  tempObj[item] = obj2[item];
88
97
  return;
89
98
  }
99
+ if (hasReplaceConfig && obj2.replaceConfig.includes(item)) {
100
+ tempObj[item] = obj2[item];
101
+ return;
102
+ }
90
103
  tempObj[item] = [...obj1[item], ...obj2[item]];
91
104
  }
92
105
  });
93
106
  return { ...obj1, ...tempObj };
94
107
  }
95
- var fs, defaultConfig2, createConfigFile;
108
+ var fs, path, defaultConfig2, createConfigFile;
96
109
  var init_create_config = __esm({
97
110
  "src/create-config.ts"() {
98
111
  "use strict";
99
112
  init_esm_shims();
100
113
  fs = __require("fs");
114
+ path = __require("path");
101
115
  ({ defaultConfig: defaultConfig2 } = (init_default_config(), __toCommonJS(default_config_exports)));
102
- createConfigFile = (filePath, options) => {
103
- const configs = mergeConfig(defaultConfig2, options);
116
+ createConfigFile = (filePath, options, packageManager) => {
117
+ const restDefaultConfig = { ...defaultConfig2 };
118
+ if (packageManager) {
119
+ const pixelDir = path.dirname(findRealModulePath("@mekari/pixel3"));
120
+ const extend = `${pixelDir}/**/dist/**/*.{js,mjs}`;
121
+ const finalInclude = [...restDefaultConfig.include, extend];
122
+ restDefaultConfig.include = finalInclude;
123
+ }
124
+ const configs = mergeConfig(restDefaultConfig, options);
104
125
  const data = "export default" + JSON.stringify(configs, null, 2);
105
126
  try {
106
127
  fs.writeFileSync(filePath, data, "utf-8");
@@ -114,10 +135,24 @@ var init_create_config = __esm({
114
135
  // src/index.ts
115
136
  import { Builder } from "@pandacss/node";
116
137
  import { createRequire } from "module";
117
- import path from "path";
138
+ import path2 from "path";
118
139
  function isValidCss(file) {
119
140
  const [filePath] = file.split("?");
120
- return path.extname(filePath) === ".css";
141
+ return path2.extname(filePath) === ".css";
142
+ }
143
+ function getPackageManager() {
144
+ const userAgent = process.env.npm_config_user_agent;
145
+ let result = "";
146
+ if (userAgent) {
147
+ if (userAgent.includes("pnpm")) {
148
+ result = "pnpm";
149
+ } else if (userAgent.includes("npm")) {
150
+ result = "npm";
151
+ } else {
152
+ result = "yarn";
153
+ }
154
+ }
155
+ return result;
121
156
  }
122
157
  var require2, tmp, PLUGIN_NAME, tmpobj, configPath, builder, nodeModulesRegex, shouldSkip, pixelcss, src_default;
123
158
  var init_src = __esm({
@@ -144,7 +179,9 @@ var init_src = __esm({
144
179
  };
145
180
  pixelcss = (options = {}) => {
146
181
  const { cwd } = options;
147
- createConfigFile(configPath, options);
182
+ const packageManager = getPackageManager();
183
+ createConfigFile(configPath, options, packageManager);
184
+ console.log("Using package manager", packageManager);
148
185
  console.log("Pixel Config (auto-generated) :", configPath);
149
186
  return {
150
187
  postcssPlugin: PLUGIN_NAME,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mekari/pixel3-postcss",
3
- "version": "0.0.6",
3
+ "version": "0.0.7-dev.1",
4
4
  "description": "PostCSS integration for Pixel 3",
5
5
  "main": "./dist/index.js",
6
6
  "author": "Sastra Nababan",