sela-core 1.0.0 → 1.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0BpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQnD"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQnD"}
@@ -36,7 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.registerInit = registerInit;
37
37
  const fs = __importStar(require("fs"));
38
38
  const path = __importStar(require("path"));
39
- const CONFIG_TEMPLATE_TS = `import { defineConfig } from 'sela';
39
+ const PACKAGE_NAME = 'sela-core';
40
+ const CONFIG_TEMPLATE_TS = `import { defineConfig } from '${PACKAGE_NAME}';
40
41
 
41
42
  export default defineConfig({
42
43
  healingPolicy: 'balanced',
@@ -45,7 +46,7 @@ export default defineConfig({
45
46
  dnaStoragePath: 'sela-snapshots',
46
47
  });
47
48
  `;
48
- const CONFIG_TEMPLATE_JS = `const { defineConfig } = require('sela');
49
+ const CONFIG_TEMPLATE_JS = `const { defineConfig } = require('${PACKAGE_NAME}');
49
50
 
50
51
  module.exports = defineConfig({
51
52
  healingPolicy: 'balanced',
@@ -59,7 +60,7 @@ function registerInit(program) {
59
60
  program
60
61
  .command('init')
61
62
  .description('Initialize Sela in the current project')
62
- .option('--update-imports', 'Swap @playwright/test imports to sela in spec files')
63
+ .option('--no-update-imports', 'Skip swapping @playwright/test imports to sela-core')
63
64
  .action(async (opts) => {
64
65
  await runInit(opts);
65
66
  });
@@ -81,6 +82,7 @@ async function runInit(opts) {
81
82
  console.error(`✅ Created ${configFile}`);
82
83
  }
83
84
  // ── Environment variables ────────────────────────────────────────
85
+ loadDotEnv(cwd);
84
86
  const missing = REQUIRED_ENV_VARS.filter((k) => !process.env[k]);
85
87
  if (missing.length > 0) {
86
88
  console.error(`\n⚠️ Missing environment variables:`);
@@ -91,19 +93,38 @@ async function runInit(opts) {
91
93
  else {
92
94
  console.error(`✅ Environment variables OK`);
93
95
  }
94
- // ── Optional import swap ─────────────────────────────────────────
95
- if (opts.updateImports) {
96
+ // ── Import swap (default ON; opt out with --no-update-imports) ──
97
+ if (opts.updateImports !== false) {
96
98
  const swapped = swapImports(cwd, isTs);
97
- console.error(`✅ Updated imports in ${swapped} spec file(s)`);
99
+ if (swapped > 0) {
100
+ console.error(`✅ Updated imports in ${swapped} spec file(s) → '${PACKAGE_NAME}'`);
101
+ }
102
+ else {
103
+ console.error(`ℹ️ No @playwright/test imports to swap`);
104
+ }
105
+ }
106
+ console.error(`\n📖 Spec files should import from:`);
107
+ console.error(` import { test, expect } from '${PACKAGE_NAME}'\n`);
108
+ }
109
+ function loadDotEnv(cwd) {
110
+ const envPath = path.join(cwd, '.env');
111
+ if (!fs.existsSync(envPath))
112
+ return;
113
+ try {
114
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
115
+ const dotenv = require('dotenv');
116
+ dotenv.config({ path: envPath });
117
+ }
118
+ catch {
119
+ // dotenv missing — skip silently
98
120
  }
99
- console.error(`\n📖 Replace imports in your spec files:`);
100
- console.error(` from: import { test, expect } from '@playwright/test'`);
101
- console.error(` to: import { test, expect } from 'sela'\n`);
102
121
  }
103
122
  function walkDir(dir, exts) {
104
123
  const results = [];
105
- const ignore = new Set(['node_modules', 'dist', '.git']);
124
+ const ignore = new Set(['node_modules', 'dist', '.git', 'sela-snapshots', 'fixwright-snapshots', 'test-results', 'playwright-report']);
106
125
  function walk(current) {
126
+ if (!fs.existsSync(current))
127
+ return;
107
128
  for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
108
129
  if (entry.isDirectory()) {
109
130
  if (!ignore.has(entry.name))
@@ -118,12 +139,15 @@ function walkDir(dir, exts) {
118
139
  return results;
119
140
  }
120
141
  function swapImports(cwd, isTs) {
121
- const exts = isTs ? ['.spec.ts', '.test.ts'] : ['.spec.js', '.test.js'];
142
+ const exts = isTs
143
+ ? ['.spec.ts', '.test.ts', '.spec.js', '.test.js']
144
+ : ['.spec.js', '.test.js'];
122
145
  const files = walkDir(cwd, exts);
123
146
  let swapped = 0;
147
+ const importRegex = /(from\s+|require\s*\(\s*)(['"])@playwright\/test\2/g;
124
148
  for (const filePath of files) {
125
149
  const content = fs.readFileSync(filePath, 'utf8');
126
- const updated = content.replace(/from\s+['"]@playwright\/test['"]/g, `from 'sela'`);
150
+ const updated = content.replace(importRegex, (_m, prefix, quote) => `${prefix}${quote}${PACKAGE_NAME}${quote}`);
127
151
  if (updated !== content) {
128
152
  fs.writeFileSync(filePath, updated, 'utf8');
129
153
  swapped++;
package/dist/cli/index.js CHANGED
@@ -1,5 +1,47 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ // Load .env from CWD before anything else reads process.env
37
+ const path = __importStar(require("path"));
38
+ try {
39
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
40
+ require('dotenv').config({ path: path.join(process.cwd(), '.env') });
41
+ }
42
+ catch {
43
+ // dotenv missing or .env absent — continue silently
44
+ }
3
45
  const commander_1 = require("commander");
4
46
  const ErrorHandler_js_1 = require("./ErrorHandler.js");
5
47
  const init_js_1 = require("./commands/init.js");
@@ -16,7 +58,7 @@ const program = new commander_1.Command();
16
58
  program
17
59
  .name('sela')
18
60
  .description('Sela CLI — proactive DNA management for Fixwright')
19
- .version('1.0.0')
61
+ .version('1.0.1')
20
62
  .exitOverride(ErrorHandler_js_1.handleError)
21
63
  .configureOutput({ outputError: () => { } });
22
64
  // ── sela init ────────────────────────────────────────────────────────────────
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
+ export { defineConfig } from './config/defineConfig.js';
2
+ export type { SelaConfig, ResolvedConfig } from './config/SelaConfig.js';
1
3
  export type * from '@playwright/test';
2
4
  export { chromium, firefox, webkit, devices, selectors } from '@playwright/test';
3
5
  export { test } from './fixtures/index.js';
4
6
  export { expect } from './fixtures/moduleExpect.js';
5
- export { defineConfig } from './config/defineConfig.js';
6
- export type { SelaConfig, ResolvedConfig } from './config/SelaConfig.js';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,mBAAmB,kBAAkB,CAAC;AAGtC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIjF,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAI3C,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGzE,mBAAmB,kBAAkB,CAAC;AAGtC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIjF,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAI3C,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
- // Sela — AI self-healing Playwright wrapper
2
+ // sela-core — AI self-healing Playwright wrapper
3
3
  //
4
4
  // Drop-in replacement for @playwright/test:
5
- // import { test, expect } from 'sela'
6
- //
7
- // All Playwright primitives are re-exported. Only `test` and `expect`
8
- // are overridden with Sela's healing versions.
5
+ // import { test, expect } from 'sela-core'
9
6
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.defineConfig = exports.expect = exports.test = exports.selectors = exports.devices = exports.webkit = exports.firefox = exports.chromium = void 0;
7
+ exports.expect = exports.test = exports.selectors = exports.devices = exports.webkit = exports.firefox = exports.chromium = exports.defineConfig = void 0;
8
+ // Config DSL exported FIRST so `sela.config.ts` can `import { defineConfig }`
9
+ // without triggering the heavier fixtures/engine graph during config load.
10
+ var defineConfig_js_1 = require("./config/defineConfig.js");
11
+ Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return defineConfig_js_1.defineConfig; } });
11
12
  // Playwright value exports (launchers, devices, etc.)
12
13
  var test_1 = require("@playwright/test");
13
14
  Object.defineProperty(exports, "chromium", { enumerable: true, get: function () { return test_1.chromium; } });
@@ -19,10 +20,7 @@ Object.defineProperty(exports, "selectors", { enumerable: true, get: function ()
19
20
  // locator proxy, and fixture-scoped healing expect
20
21
  var index_js_1 = require("./fixtures/index.js");
21
22
  Object.defineProperty(exports, "test", { enumerable: true, get: function () { return index_js_1.test; } });
22
- // Sela's healing expect — works standalone (import { expect } from 'sela')
23
+ // Sela's healing expect — works standalone (import { expect } from 'sela-core')
23
24
  // Detects page from locator, falls back to raw PW expect for non-locators
24
25
  var moduleExpect_js_1 = require("./fixtures/moduleExpect.js");
25
26
  Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return moduleExpect_js_1.expect; } });
26
- // Config DSL — defineConfig() provides TypeScript inference for sela.config.ts
27
- var defineConfig_js_1 = require("./config/defineConfig.js");
28
- Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return defineConfig_js_1.defineConfig; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sela-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "AI self-healing Playwright wrapper — drop-in replacement for @playwright/test",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "devDependencies": {
58
58
  "@playwright/test": "^1.58.2",
59
59
  "@types/jest": "^30.0.0",
60
- "@types/node": "^25.6.0",
60
+ "@types/node": "^25.6.2",
61
61
  "jest": "^30.3.0",
62
62
  "jsdom": "^29.0.1",
63
63
  "ts-jest": "^29.4.6",